Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JUnit 4 Test Suites

How do I create test suites with JUnit 4?

All the documentation I've seen doesn't seem to be working for me. And if I use the Eclipse wizard it doesn't give me an option to select any of the test classes I have created.

like image 239
Adam Taylor Avatar asked Jan 19 '09 11:01

Adam Taylor


People also ask

What is JUnit test suite?

Test suite is used to bundle a few unit test cases and run them together. In JUnit, both @RunWith and @Suite annotations are used to run the suite tests. This chapter takes an example having two test classes, TestJunit1 & TestJunit2, that run together using Test Suite.

Does JUnit Support Suite test?

We can use the @Suite, @SelectPackages, and @SelectClasses annotations to group test cases and run them as a suite in JUnit 5. A suite is a collection of test cases that we can group together and run as a single test.

Is JUnit 4 still supported?

The platform changes in a highly incompatible way and the Vintage engine will no longer be supported. This is not to be expected in the near future.

Is JUnit 4 better than JUnit 5?

JUnit 5 Advantages We need to import the whole library, even when we only require a particular feature. In JUnit 5, we get more granularity, and can import only what's necessary. Only one test runner can execute tests at a time in JUnit 4 (e.g. SpringJUnit4ClassRunner or Parameterized ).


1 Answers

import org.junit.runners.Suite; import org.junit.runner.RunWith;  @RunWith(Suite.class) @Suite.SuiteClasses({TestClass1.class, TestClass2.class}) public class TestSuite {   //nothing } 
like image 171
Joachim Sauer Avatar answered Sep 23 '22 12:09

Joachim Sauer