Do you think it's a good idea to use JUnit and TestNG together in one project? I need some features from TestNG, but I also need JUnit specific extensions, like DbUnit and XmlUnit.
And if I use them together, do you think I should put both test package trees in the same "test" folder in my Eclipse project?
DBUnit works fine with TestNG but nevertheless, you can run both JUnit 3 and TestNG tests at the same time: all you need to do is to put your JUnit 3 classes in a tag
<test junit="true">
</test>
and all your other TestNG classes in a regular:
<test>
</test>
Look for the string "junit" in the documentation for more details.
Why can't you use DBUnit with TestNG? As far as I can tell, it doesn't have anything specific to TestNG. Just have to define the import in TestNG's before test, and afterTest.
I would be surprised if XMLUnit couldn't be used in a similar matter.
Related
TFS and TestNG - Possible to Execute TestNG test(s) within TFS2015?
I have uploaded a Java Maven project to a Repo in my instance of TFS.
My java Maven project comprises of TestNG Test / classes
I can see that there is a Maven plugin within the TFS which also has a JUnit link.
4. I cant see any option to enable me to execute TestNG tests within the TFS, is it even possible?
It's able to use Maven task to build a Java application or test the application including TestNG test. Detail steps please refer this tutorial: Get started testing Java applications with Visual Studio Team Services
For test result report just follow juherr's reply in this question.
Yes you should be able to run your TestNG tests.
I think its eventually going to be Maven that is going to be executing your tests.
Maven makes use of surefire-plugin to basically execute your tests. For TestNG here's two of executing tests via surefire-plugin
If your test matches the default pattern "/Test*.java", "/*Test.java", "**/*TestCase.java" (See here)
Create a suite xml file for TestNG (See here) and have surefire plugin refer to it (see here).
I found information about migrating from JUnit to TestNG in general (here for example) and about working in IntelliJ IDEA with JUnit and TestNG separately, but nothing about migrating from JUnit to TestNG in IntelliJ IDEA itself.
Can anyone describe the steps required to do this?
Does Maven surefire require a testng.xml file to run testng classes and methods? I have a multi module reactor setup in maven. Testng and some custom tools are located on one module and our tests are located on another module. Our structure is like this
/pom.xml
/testng-utils/pom.xml
/testng-utils/src
/tests/pom.xml
/tests/src
The tests module has a dependency on testng utils. testng-utils module brings in testng and hamcrest. Surefire is a plugin in tests/pom.xml.
I use testng annotations inside my tests, and I don't use an testng.xml file, I realize I'm providing very little information so I'm not expecting anything too in depth for an answer, just maybe a hint as to why my tests aren't being found.
Does anyone use a setup at all similar to this, and invoke testng without the use of a testng.xml file through surefire? I can try to include more information if anyone wants it if I'm able, but this is for the company I work for so I can't put much.
Thanks!
As long as you place your tests under src/test/java directory and follow the *Test.java naming convention surefire should be able to pick them up without any further configuration.
Surefire + TestNG
I'm looking at adding TestNG support to http://pitest.org and could do with some real and dirty code to try it out on.
Can anyone suggest some smallish open source projects that are build using maven and use TestNG for unit testing?
For clarity - I am not asking how to configure maven to use TestNG, I am looking for some example projects to use as input to a mutation testing tool.
Off the top of my head, Seam and Tapestry both use TestNG. Obviously, TestNG itself uses TestNG.
There is also a lot of activity on the Selenium front, check out the Selenium boards.
Usually you only need to add the testng dependency to your pom with scope test and surefire will handle that already...(may be you need to update surefire plugin).
We have a bunch junit tests in our current project. Essentially we are looking for a way to run all the test in a given package. Currently in Netbeans I see you can run all the tests or a single test, but no way to run a a sub-set of tests.
Is this built into Netbeans? Or is there another way we can do this?
In JUnit this is achieved through TestSuite. You can check for more information here (look at the code, not at the pictures).
At least in the Eclipse IDE there is a functionality that lets you add a new TestSuite, select which tests it is to include and then have the IDE generate it for you.
I haven't seen such thing in Netbeans, but you should check for any additional JUnit plugins.
Just set up junit test groups like documented e.g. on this question and then run the test group via your ant or maven build.