5 improved answer
source | link

TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionalities that make it more powerful and easier to use.

TestNG is designed to cover all categories of tests: unit, functional, end-to-end, integration, etc...

Additional Features:

  • Annotations.
  • Run your tests in arbitrarily big thread pools with various policies available (all methods in their own thread, one thread per test class, etc...).
  • Test that your code is multithread safe.
  • Flexible test configuration. Support for data-driven testing (with @DataProvider).
  • Support for parameters.
  • Powerful execution model (no more TestSuite).
  • Supported by a variety of tools and plug-ins (Eclipse, IDEA, Maven, etc...).
  • Embeds BeanShell for further flexibility.
  • Default JDK functions for runtime and logging (no dependencies). 
  • Dependent methods for application server testing.
  • Facilitates user with effective means of Report Generation using ReportNG

Annotations:

JUnit: @BeforeClass and @AfterClass methods have to be declared as static. TestNG does not have this constraint.

TestNG: It has provided four additional setup/teardown pairs for the suite, test and groups, i.e. @BeforeSuite, @AfterSuite, @BeforeTest, @AfterTest, @BeforeGroups and @AfterGroups, @BeforeMethod, @BeforeClass, @AfterClass and @AfterMethod.

Parameterized test:

This feature is implemented in both tools, however in quite different ways.

TestNG has basically two ways for providing varying parameter values to a test method: by setting the testng.xml, and by defining a @DataProvider method.

In JUnit, @RunWith and @Parameters are used together to facilitate parameterized tests, while the @Parameters method has to return List[] with all the actual values, which will be fed into a dedicated class constructor as an argument.

Why choose TestNG?

I've talked about the features that differentiate TestNG for me, but there are a few more that aren't yet available in JUnit. For example, TestNG uses test groups, which can categorize tests according to features such as run times. As I said at the beginning of this column, JUnit 4 and TestNG are similar on the surface. But whereas JUnit is designed to hone in on a unit of code, TestNG is meant for high-level testing. Its flexibility is especially useful with large test suites, where one test's failure shouldn't mean having to rerun a suite of thousands.
Each framework has its strengths, and there's nothing stopping you from using both in concert.

enter image description here

TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionalities that make it more powerful and easier to use.

TestNG is designed to cover all categories of tests: unit, functional, end-to-end, integration, etc...

Additional Features:

  • Annotations.
  • Run your tests in arbitrarily big thread pools with various policies available (all methods in their own thread, one thread per test class, etc...).
  • Test that your code is multithread safe.
  • Flexible test configuration. Support for data-driven testing (with @DataProvider).
  • Support for parameters.
  • Powerful execution model (no more TestSuite).
  • Supported by a variety of tools and plug-ins (Eclipse, IDEA, Maven, etc...).
  • Embeds BeanShell for further flexibility.
  • Default JDK functions for runtime and logging (no dependencies). Dependent methods for application server testing.

Annotations:

JUnit: @BeforeClass and @AfterClass methods have to be declared as static. TestNG does not have this constraint.

TestNG: It has provided four additional setup/teardown pairs for the suite, test and groups, i.e. @BeforeSuite, @AfterSuite, @BeforeTest, @AfterTest, @BeforeGroups and @AfterGroups, @BeforeMethod, @BeforeClass, @AfterClass and @AfterMethod.

Parameterized test:

This feature is implemented in both tools, however in quite different ways.

TestNG has basically two ways for providing varying parameter values to a test method: by setting the testng.xml, and by defining a @DataProvider method.

In JUnit, @RunWith and @Parameters are used together to facilitate parameterized tests, while the @Parameters method has to return List[] with all the actual values, which will be fed into a dedicated class constructor as an argument.

Why choose TestNG?

I've talked about the features that differentiate TestNG for me, but there are a few more that aren't yet available in JUnit. For example, TestNG uses test groups, which can categorize tests according to features such as run times. As I said at the beginning of this column, JUnit 4 and TestNG are similar on the surface. But whereas JUnit is designed to hone in on a unit of code, TestNG is meant for high-level testing. Its flexibility is especially useful with large test suites, where one test's failure shouldn't mean having to rerun a suite of thousands.
Each framework has its strengths, and there's nothing stopping you from using both in concert.

enter image description here

TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionalities that make it more powerful and easier to use.

TestNG is designed to cover all categories of tests: unit, functional, end-to-end, integration, etc...

Additional Features:

  • Annotations.
  • Run your tests in arbitrarily big thread pools with various policies available (all methods in their own thread, one thread per test class, etc...).
  • Test that your code is multithread safe.
  • Flexible test configuration. Support for data-driven testing (with @DataProvider).
  • Support for parameters.
  • Powerful execution model (no more TestSuite).
  • Supported by a variety of tools and plug-ins (Eclipse, IDEA, Maven, etc...).
  • Embeds BeanShell for further flexibility.
  • Default JDK functions for runtime and logging (no dependencies). 
  • Dependent methods for application server testing.
  • Facilitates user with effective means of Report Generation using ReportNG

Annotations:

JUnit: @BeforeClass and @AfterClass methods have to be declared as static. TestNG does not have this constraint.

TestNG: It has provided four additional setup/teardown pairs for the suite, test and groups, i.e. @BeforeSuite, @AfterSuite, @BeforeTest, @AfterTest, @BeforeGroups and @AfterGroups, @BeforeMethod, @BeforeClass, @AfterClass and @AfterMethod.

Parameterized test:

This feature is implemented in both tools, however in quite different ways.

TestNG has basically two ways for providing varying parameter values to a test method: by setting the testng.xml, and by defining a @DataProvider method.

In JUnit, @RunWith and @Parameters are used together to facilitate parameterized tests, while the @Parameters method has to return List[] with all the actual values, which will be fed into a dedicated class constructor as an argument.

Why choose TestNG?

I've talked about the features that differentiate TestNG for me, but there are a few more that aren't yet available in JUnit. For example, TestNG uses test groups, which can categorize tests according to features such as run times. As I said at the beginning of this column, JUnit 4 and TestNG are similar on the surface. But whereas JUnit is designed to hone in on a unit of code, TestNG is meant for high-level testing. Its flexibility is especially useful with large test suites, where one test's failure shouldn't mean having to rerun a suite of thousands.
Each framework has its strengths, and there's nothing stopping you from using both in concert.

enter image description here

4 improved answer
source | link

TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionalities that make it more powerful and easier to use.

TestNG is designed to cover all categories of tests: unit, functional, end-to-end, integration, etc...

JUnit 4 and TestNG are both very popular unit test framework in Java. However, TestNG's goal is much wider, which includes not only unit testing, but also support of integration and acceptance testing, etc. Which one is better or more suitable depends on use contexts and requirements.Additional Features:

Annotations:
JUnit:

  • Annotations.
  • Run your tests in arbitrarily big thread pools with various policies available (all methods in their own thread, one thread per test class, etc...).
  • Test that your code is multithread safe.
  • Flexible test configuration. Support for data-driven testing (with @DataProvider).
  • Support for parameters.
  • Powerful execution model (no more TestSuite).
  • Supported by a variety of tools and plug-ins (Eclipse, IDEA, Maven, etc...).
  • Embeds BeanShell for further flexibility.
  • Default JDK functions for runtime and logging (no dependencies). Dependent methods for application server testing.

@BeforeClass and @AfterClass methods have to be declared as static. TestNG does not have this constraint.Annotations:

JUnit: @BeforeClass and @AfterClass methods have to be declared as static. TestNG does not have this constraint.

TestNG: It has provided four additional setup/teardown pairs for the suite, test and groups, i.e. @BeforeSuite, @AfterSuite, @BeforeTest, @AfterTest, @BeforeGroups and @AfterGroups, @BeforeMethod, @BeforeClass, @AfterClass and @AfterMethod.

It has provided four additional setup/teardown pairs for the suite, test and groups, i.e. @BeforeSuite, @AfterSuite, @BeforeTest, @AfterTest, @BeforeGroup and @AfterGroup, @BeforeMethod and @AfterMethod.Parameterized test:

Parameterized test:
This This feature is implemented in both tools, however in quite different ways.

TestNG has basically two ways for providing varying parameter values to a test method: by setting the testng.xml, and by defining a @DataProvider method.

In JUnit, @RunWith and @Parameters are used together to facilitate parameterized tests, while the @Parameters method has to return List[] with all the actual values, which will be fed into a dedicated class constructor as an argument.

Why choose TestNG?

Why choose TestNG?
I've I've talked about the features that differentiate TestNG for me, but there are a few more that aren't yet available in JUnit. For example, TestNG uses test groups, which can categorize tests according to features such as run times. As I said at the beginning of this column, JUnit 4 and TestNG are similar on the surface. But whereas JUnit is designed to hone in on a unit of code, TestNG is meant for high-level testing. Its flexibility is especially useful with large test suites, where one test's failure shouldn't mean having to rerun a suite of thousands.
Each framework has its strengths, and there's nothing stopping you from using both in concert.

enter image description here

JUnit 4 and TestNG are both very popular unit test framework in Java. However, TestNG's goal is much wider, which includes not only unit testing, but also support of integration and acceptance testing, etc. Which one is better or more suitable depends on use contexts and requirements.

Annotations:
JUnit:

@BeforeClass and @AfterClass methods have to be declared as static. TestNG does not have this constraint.

TestNG:

It has provided four additional setup/teardown pairs for the suite, test and groups, i.e. @BeforeSuite, @AfterSuite, @BeforeTest, @AfterTest, @BeforeGroup and @AfterGroup, @BeforeMethod and @AfterMethod.

Parameterized test:
This feature is implemented in both tools, however in quite different ways.

TestNG has basically two ways for providing varying parameter values to a test method: by setting the testng.xml, and by defining a @DataProvider method.

In JUnit, @RunWith and @Parameters are used together to facilitate parameterized tests, while the @Parameters method has to return List[] with all the actual values, which will be fed into a dedicated class constructor as an argument.

Why choose TestNG?
I've talked about the features that differentiate TestNG for me, but there are a few more that aren't yet available in JUnit. For example, TestNG uses test groups, which can categorize tests according to features such as run times. As I said at the beginning of this column, JUnit 4 and TestNG are similar on the surface. But whereas JUnit is designed to hone in on a unit of code, TestNG is meant for high-level testing. Its flexibility is especially useful with large test suites, where one test's failure shouldn't mean having to rerun a suite of thousands.
Each framework has its strengths, and there's nothing stopping you from using both in concert.

enter image description here

TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionalities that make it more powerful and easier to use.

TestNG is designed to cover all categories of tests: unit, functional, end-to-end, integration, etc...

Additional Features:

  • Annotations.
  • Run your tests in arbitrarily big thread pools with various policies available (all methods in their own thread, one thread per test class, etc...).
  • Test that your code is multithread safe.
  • Flexible test configuration. Support for data-driven testing (with @DataProvider).
  • Support for parameters.
  • Powerful execution model (no more TestSuite).
  • Supported by a variety of tools and plug-ins (Eclipse, IDEA, Maven, etc...).
  • Embeds BeanShell for further flexibility.
  • Default JDK functions for runtime and logging (no dependencies). Dependent methods for application server testing.

Annotations:

JUnit: @BeforeClass and @AfterClass methods have to be declared as static. TestNG does not have this constraint.

TestNG: It has provided four additional setup/teardown pairs for the suite, test and groups, i.e. @BeforeSuite, @AfterSuite, @BeforeTest, @AfterTest, @BeforeGroups and @AfterGroups, @BeforeMethod, @BeforeClass, @AfterClass and @AfterMethod.

Parameterized test:

This feature is implemented in both tools, however in quite different ways.

TestNG has basically two ways for providing varying parameter values to a test method: by setting the testng.xml, and by defining a @DataProvider method.

In JUnit, @RunWith and @Parameters are used together to facilitate parameterized tests, while the @Parameters method has to return List[] with all the actual values, which will be fed into a dedicated class constructor as an argument.

Why choose TestNG?

I've talked about the features that differentiate TestNG for me, but there are a few more that aren't yet available in JUnit. For example, TestNG uses test groups, which can categorize tests according to features such as run times. As I said at the beginning of this column, JUnit 4 and TestNG are similar on the surface. But whereas JUnit is designed to hone in on a unit of code, TestNG is meant for high-level testing. Its flexibility is especially useful with large test suites, where one test's failure shouldn't mean having to rerun a suite of thousands.
Each framework has its strengths, and there's nothing stopping you from using both in concert.

enter image description here

3 improved answer
source | link

JUnit 4 and TestNG are both very popular unit test framework in Java. However, TestNG's goal is much wider, which includes not only unit testing, but also support of integration and acceptance testing, etc. Which one is better or more suitable depends on use contexts and requirements.

Annotations:
JUnit:JUnit:

@BeforeClass and @AfterClass@BeforeClass and @AfterClass methods have to be declared as static. TestNG does not have this constraint.

TestNG:TestNG:

It has provided four additional setup/teardown pairs for the suite, test and groups, i.e. @BeforeSuite, @AfterSuite, @BeforeTest, @AfterTest, @BeforeGroup and @AfterGroup, @BeforeMethod and @AfterMethod@BeforeSuite, @AfterSuite, @BeforeTest, @AfterTest, @BeforeGroup and @AfterGroup, @BeforeMethod and @AfterMethod.

Parameterized test:
This feature is implemented in both tools, however in quite different ways.

TestNG has basically two ways for providing varying parameter values to a test method: by setting the testng.xml, and by defining a @DataProvider method.

In JUnit, @RunWith and @Parameters are used together to facilitate parameterized tests, while the @Parameters method has to return List[] with all the actual values, which will be fed into a dedicated class constructor as an argument.

Why choose TestNG?
I've talked about the features that differentiate TestNG for me, but there are a few more that aren't yet available in JUnit. For example, TestNG uses test groups, which can categorize tests according to features such as run times. As I said at the beginning of this column, JUnit 4 and TestNG are similar on the surface. But whereas JUnit is designed to hone in on a unit of code, TestNG is meant for high-level testing. Its flexibility is especially useful with large test suites, where one test's failure shouldn't mean having to rerun a suite of thousands.
Each framework has its strengths, and there's nothing stopping you from using both in concert.

enter image description here

JUnit 4 and TestNG are both very popular unit test framework in Java. However, TestNG's goal is much wider, which includes not only unit testing, but also support of integration and acceptance testing, etc. Which one is better or more suitable depends on use contexts and requirements.

Annotations:
JUnit:

@BeforeClass and @AfterClass methods have to be declared as static. TestNG does not have this constraint.

TestNG:

It has provided four additional setup/teardown pairs for the suite, test and groups, i.e. @BeforeSuite, @AfterSuite, @BeforeTest, @AfterTest, @BeforeGroup and @AfterGroup, @BeforeMethod and @AfterMethod.

Parameterized test:
This feature is implemented in both tools, however in quite different ways.

TestNG has basically two ways for providing varying parameter values to a test method: by setting the testng.xml, and by defining a @DataProvider method.

In JUnit, @RunWith and @Parameters are used together to facilitate parameterized tests, while the @Parameters method has to return List[] with all the actual values, which will be fed into a dedicated class constructor as an argument.

Why choose TestNG?
I've talked about the features that differentiate TestNG for me, but there are a few more that aren't yet available in JUnit. For example, TestNG uses test groups, which can categorize tests according to features such as run times. As I said at the beginning of this column, JUnit 4 and TestNG are similar on the surface. But whereas JUnit is designed to hone in on a unit of code, TestNG is meant for high-level testing. Its flexibility is especially useful with large test suites, where one test's failure shouldn't mean having to rerun a suite of thousands.
Each framework has its strengths, and there's nothing stopping you from using both in concert.

enter image description here

JUnit 4 and TestNG are both very popular unit test framework in Java. However, TestNG's goal is much wider, which includes not only unit testing, but also support of integration and acceptance testing, etc. Which one is better or more suitable depends on use contexts and requirements.

Annotations:
JUnit:

@BeforeClass and @AfterClass methods have to be declared as static. TestNG does not have this constraint.

TestNG:

It has provided four additional setup/teardown pairs for the suite, test and groups, i.e. @BeforeSuite, @AfterSuite, @BeforeTest, @AfterTest, @BeforeGroup and @AfterGroup, @BeforeMethod and @AfterMethod.

Parameterized test:
This feature is implemented in both tools, however in quite different ways.

TestNG has basically two ways for providing varying parameter values to a test method: by setting the testng.xml, and by defining a @DataProvider method.

In JUnit, @RunWith and @Parameters are used together to facilitate parameterized tests, while the @Parameters method has to return List[] with all the actual values, which will be fed into a dedicated class constructor as an argument.

Why choose TestNG?
I've talked about the features that differentiate TestNG for me, but there are a few more that aren't yet available in JUnit. For example, TestNG uses test groups, which can categorize tests according to features such as run times. As I said at the beginning of this column, JUnit 4 and TestNG are similar on the surface. But whereas JUnit is designed to hone in on a unit of code, TestNG is meant for high-level testing. Its flexibility is especially useful with large test suites, where one test's failure shouldn't mean having to rerun a suite of thousands.
Each framework has its strengths, and there's nothing stopping you from using both in concert.

enter image description here

2 improved answer
source | link
1
source | link