Junit

Popular unit testing framework for Java and Scala

Testng

TestNG is a testing framework focused on providing both unit and functional testing abilities in the Java programming language



Framework frameworks testng

Example

"In case if you have flexibility to choose another testing framework you can try with testng which has bigger feature set than junit"

from question  

Running multiple test in parallel with Multithreading

"The spock framework which runs on top of junit has much better support for parameterized testing which is what you seem to want than either plain junit or testng"

from question  

How can i test multiple java files with the same junit?

"Now concerning testing frameworks there are junit or testng;i don t want to start holy war but imo junit is better and more widespread and hence is more actively developed"

from question  

Whether Selenium + JUnit is the best practice to test web application in the industry now?

Hey best android

Example

"If you re doing non-unit testing testng might be a better option than junit"

from question  

Configuring system tests in junit

"I actually picked junit over testng for android testing i thought android testing was more lightweight than testng for on-device testing"

from question  

Why does Android use JUnit over TestNG even if Cedric Beust created TestNg and was part of Android team?

"Hey might not be exactly what you want but they are probably the best you get with junit;supposedly testng has better test grouping possibilities but i haven t really looked into it myself yet"

from question  

Junit 4 test suite and individual test classes

Easier please better

Example

"Isn t testng supposed to a better than junit"

from question  

Why does Android use JUnit over TestNG even if Cedric Beust created TestNg and was part of Android team?

"If you are familiar of using junit it is easier to switch into testng"

from question  

Is TestNG enough as a web test framework?

"I know this can be achieved with junit but in my experience it is easier with testng"

from question  

How can I parallelize multiple instances of the same Selenium suite using Junit?

"All of which junit needs or does poorly;testng even has better reporting please google for reportng or my fav testng-xlst"

from question  

JUnit vs TestNg - For a New Project that using Spring MVC

Look unit for

Example

"Junit is more aimed at unit testing;for functional testing take a look at testng which offers advanced functional testing features such as"

from question  

Functional Testing in Java

"As far as i know junit does not support the behaviour that you want;you might want to take a look at testng which allows test specific setup with beforemethod and aftermethod annotations"

from question  

Set up JUnit test database

Others

Example

Firstly i am not sure how to properly use multi-thread with junit last time i tried i had no success anyway i have had better results with testng

from question  

TimeoutException when running Selenium tests in parallel

Here is what it would look like with testng it s a little more contrived with junit since you can t pass parameters directly to test functions

from question  

How to write junit tests for interfaces?

Testng from a very early stage was suitable for integration automation testing it has a more powerful version of dataprovider than junit even before junit had dataprovider capabilities;it has much better annotation support than junit and unlike junit testng does not require your before after class methods to be static

from question  

JUnit vs TestNg - For a New Project that using Spring MVC

The junit complies the code and we can even have data pushed into the actual database and rolled back after testing;the testng does not provide this facility

from question  

TestNG testcases fails in eclipse

Junit is older and have more extensions dbunit cactus etc;testng has much more annotations

from question  

What is the standard for testing in Java?

Using a profile is a possibility but it is not mandatory as grouping and excludedgroups are user properties defined in the maven surefire plugin to respectively include and exclude any junit 5 tags and it also works with junit 4 and testng test filtering mechanism

from question  

How to choose which JUnit5 Tags to execute with Maven

Testng is much friendlier to this paradigm than junit though

from question  

Where should I put my JUnit tests?

If you have to do a lot of this honestly testng is more flexible but you can absolutely get it done in junit

from question  

Data-driven tests with jUnit

Testng is more flexible than junit and have multiple advantages like support for parallel testing for example

from question  

What are some good Java web development tools (across the board)

Edit it seems junit has more printed books as references compared to testng on amazon

from question  

Which UnitTest framework to learn for Java now?

Testng offers you more options and possibilites how to run your tests and in which order especially something junit can t

from question  

First steps with Selenium and jUnit - any good tutorials?

Junit is more direct and simpel to use if you start to learn java testng has more features but maybe is more complex

from question  

How to test java code?

Testng has more capabilities and can be helpful with integration tests junit is more focused on unit tests

from question  

How to introduce tests in an underway Java project?

To be perfectly honest i junit is way more popular than testng at least here where i work and live

from question  

Which UnitTest framework to learn for Java now?

If there is a junit extension or similar framework that provides a better solution than testng then please let me know

from question  

Solution for Parameterized Tests

Testng strives to be much more configurable than junit but in the end they both work equally well

from question  

JUnit vs TestNG

Unit and integration tests use junit and can run on the jenkins master for the system tests we use testng and they can run the testfx tests on a jenkins agent. i think testng is more suited for system tests than junit development build project build unit+integration tests was already in place

from question  

How to set up Jenkins for build, unit test and system tests

I suspect what you re trying to do will be easy with testng - junit does not have the grouping capability that testng does;i always recommend that people switch to testng which is just like junit 4 except with more functionality

from question  

Parameterized suites in Junit 4?

Junit is creating a new instance of the test class before each test so junit fans like me will never face such problem;testng is not creating a new instance of test class

from question  

Mockito, @InjectMocks strange behaviour with final fields

Junit is not able to run testng tests or features;but at the opposite testng is able to run junit tests

from question  

Can I use TestNG DataProvider in Spring Context i.e. in my Test Code which runswith SpringJUnit4ClassRunner

Back to Home
Data comes from Stack Exchange with CC-BY-SA-4.0