I'm using third party tool TestRail, I need to run my UI Automation scripts using UI scripts of testRail. I need to expose an API in the src.test.java.xxxx folder instead of src.main.java.xxxx that will actually execute the TestNG tests. https://support.gurock.com/hc/en-us/articles/7344009893908-UI-scripts-introduction Spring is not allowing me to expose an API in the test folder. Is there any specific configuration required to create API in test folder? We are already using Spring in our test folder like:
package com.xxxx.selenium;
import com.xxxx.selenium.logging.LoggingAspect;
import org.springframework.context.annotation.*;
import org.springframework.stereotype.Component;
@Component
@Configuration
@ComponentScan(basePackages={"com.xxxx.selenium.*", "com.xxxx.restassured"})
@PropertySource({"classpath:application-test.properties","classpath:api-test.properties",
"classpath:taxlookup-apidata.properties"})
@EnableAspectJAutoProxy(proxyTargetClass = true)
public class TestConfig {
@Bean
public LoggingAspect loggingAspect() {
return new LoggingAspect();
}
}
@SpringBootTest(classes = TestConfig.class)
public class AbstractTest extends AbstractTestNGSpringContextTests
{
private static Logger logger = LoggerFactory.getLogger(AbstractTest.class);
@Autowired
protected LoadURL loadURL;
@Autowired
protected Menu menu;
@Autowired
protected ReportManager manager;
I have tried to run the piece of code by creating a main method in the test folder and It was executing the tests.
package com.xxxx;
import com.xxxx.selenium.listeners.TestListener;
import com.xxxx.selenium.sanitypack.BarCodeCycleCountSanity;
import org.testng.ITestNGListener;
import org.testng.TestNG;
public class Main {
public static void main(String args[]){
ITestNGListener testListener = new TestListener();
TestNG testNG = new TestNG();
testNG.setTestClasses(new Class[] {xyz.class});
testNG.addListener(testListener);
testNG.run();
}
}
I have also tried to move the above mentioned code in the main folder but the packages do not import in the main folder.