I'm trying to parameterize a JUnit4 test from a queue
previously set in one of my src/main classes. This is what I've done so far, there's a class for the test suite (MigratorTestSuite
)
@RunWith(Suite.class)
@Suite.SuiteClasses({ParameterizedTest.class})
public class MigratorTestSuite {
@BeforeClass
public static void setUp() throws SAXException, ParserConfigurationException, GitAPIException, IOException {
Migrator.getReady();
}
@AfterClass
public static void tearDown() throws SQLException {
DatabaseManager.closeConnections();
RepositoryManager.closeRepository();
}
}
And a class ParameterizedTest
where I'm figuring out how to run a parameterized JUnit test which looks as follows:
@RunWith(Parameterized.class)
public class ParameterizedTest {
@Parameterized.Parameters(name="whatever")
public static Queue<Deque<String>> data(){
return TestCasesConstructor.testCasesQueue;
}
private Deque<String> scenario;
public ParameterizedTest(Queue<Deque<String>> q){
scenario = q.peek();
}
@Before
public void initialize() throws ParserConfigurationException, IOException, SQLException, ClassNotFoundException {
System.out.println("--- Preparing database for running scripts");
DatabaseManager.dropDatabase();
DatabaseManager.createDatabase();
}
@Test
public void testPlainMigration() throws Exception {
Assert.assertTrue(Migrator.runScenario(this.scenario));
}
@After
public void after() throws SQLException {
DatabaseManager.closeConnections();
TestCasesConstructor.testCasesQueue.remove();
}
}
When I perform a mvn clean install test -Dtest=MigratorTestSuite
the result is that it doesn't find any test and when I debug it, it shows:
No tests found matching data with any parameter from
org.junit.runner.Request
atorg.junit.internal.requests.FilterRequest.getRunner
What am I doing wrong? Should I better implement it in TestNG? I'm really new to Junit.