I cannot make these two work together in eclipse
I can set up surefire plugin like this
<suiteXmlFiles>
<suiteXmlFile>${basedir}/src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<testResources>
<testResource>
<directory>${project.basedir}/src/test/java</directory>
<includes>
<include>**/*.*</include>
</includes>
</testResource>
<testResource>
<directory>${project.basedir}/src/test/resources</directory>
<includes>
<include>**/*</include>
</includes>
</testResource>
</testResources>
and run $mvn test and all resources are compiled and moved into /target/test-classes, which works fine.
But if I run $mvn clean and then use the TestNG view to run some tests, there is nothing compiled in /target/test-classes, so that I either have to run test phase before that, or somehow employ maven-compiler-plugin:testCompile goal to compile test resources …
but maven-compiler-plugin:2.3.2:testCompile isn’t setup like surefire plugin via the testResources configuration. It just compiles test source code into test-classes
What should I do to make testNG execute as if I run surefire plugin ? I somehow need the effect that results from <testResources>
testResources & resourcesis part ofmaven-resources-plugincompile & test-compileis part ofmaven-compiler-pluginSo that all you have to do is to click a button that invokes all these phases & goals before you run tests via TestNG view
Also, and this is very important, whenever you run test(s) from the TestNG view, eclipse creates a temporary
testng.xmldefinition with the test(s) you have clicked on, either a test or a class of tests. So that additional settings in testng.xml that you have when running via SureFire plugin gets lost if you are using testNG run configuration via Eclipse’s Run As … it looks like this–
It has a convenient way to deal with this – setting up a template testng.xml file in eclipse testng preferences.