I'm moving from JUnit to TestNG.
My classes already have a constructor so I've added a zero-args constructor as requested, now I notice that the @RunWith is using org.junit.runner.
I presume I need to comment out import org.junit.runner.RunWith;
but what is the TestNG equivalent I need to use?
Thanks.
All you have to do is to put JUnit library on the TestNG classpath, so it can find and use JUnit classes, change your test runner from JUnit to TestNG in Ant and then run TestNG in "mixed" mode. This way you can have all your tests in the same project, even in the same package, and start using TestNG.
You can execute your existing JUnit test cases using TestNG. TestNG can automatically recognize and run JUnit tests, so that you can use TestNG as a runner for all your existing tests and write new tests using TestNG.
Differences between JUnit and TestNG : JUnit is an open-source framework used to trigger and write tests. TestNG is a Java-based framework that is an upgraded option for running tests. JUnit does not support to run parallel tests. TestNG can run parallel tests.
Extend your test class from
org.springframework.test.context.testng.AbstractTestNGSpringContextTests.
It is the equivalent of Junit @RunWith
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With