Question

I have the following problem:

I have a parameterized test

  • it has a list of parameters
  • it has several test methods
  • test methods need a set up for each parameter

More detailed:

  • for each file in list [...]
  • parse file to several tables in db - [setUp]
  • read data from tables - [setUp]
  • and test data from each table in separate test - [tests]

I would like to execute setUp method and tests in such order

  1. initialize parameters

  2. for first parameter

    • execute setUp method with first parameter
    • execute all tests methods with first parameter
  3. for second parameter
    • execute setUp method with second parameter
    • execute all tests methods with second parameter
  4. ...

I tried JUnit and TestNG to do this and didn't find the solution. I would like to know if anyone knows how to do it.

I found a workaround for this in JUnit - place setUp and all test in one test method, and use ErrorCollector to make sure all check will be executed. But I don't like it because this way report is less clear.

Was it helpful?

Solution

It seems that this feature is in process of implementation in JUnit, but stalling. https://github.com/junit-team/junit/pull/605

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top