Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parameterized suites in Junit 4?

With @RunWith( Suite.class ) I can group test classes into a test suite and run them all together. With @RunWith( Parameterized.class ) I can run the same test for different parameters. What I want is to run a test suite for different parameters. Is there a way of doing that?

like image 423
Frank HJ Cuypers Avatar asked Apr 30 '12 17:04

Frank HJ Cuypers


People also ask

What are parameterized tests used for in JUnit?

JUnit 5, the next generation of JUnit, facilitates writing developer tests with shiny new features. One such feature is parameterized tests. This feature enables us to execute a single test method multiple times with different parameters.

What is @RunWith parameterized class?

The parameterized test class also meets the following requirements: It is annotated with @RunWith(Parameterized. class). It has a single constructor that contains the test data. It has a static method which annotated with @parameters annotation and generates and returns test data.


1 Answers

I always recommend that people switch to TestNG, which is just like JUnit 4, except with more functionality.

It has built-in support for parameterization and grouping.

I suspect what you're trying to do will be easy with TestNG - JUnit does not have the 'grouping' capability that TestNG does.

http://testng.org/doc/migrating.html

http://www.mkyong.com/unittest/testng-parameter-testing-example/

like image 155
ianpojman Avatar answered Oct 14 '22 06:10

ianpojman