Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TestNG @RunWith from JUnit

Tags:

junit

testng

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.

like image 635
userMod2 Avatar asked Nov 25 '15 12:11

userMod2


People also ask

Can you convert JUnit test scripts to TestNG?

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.

Can I use TestNG and JUnit together?

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.

How TestNG is different from JUnit?

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.


1 Answers

Extend your test class from

org.springframework.test.context.testng.AbstractTestNGSpringContextTests. 

It is the equivalent of Junit @RunWith.

like image 89
Valeriy K. Avatar answered Sep 24 '22 13:09

Valeriy K.