jeudi 9 juin 2016

Run JUnit (JAVA) tests for a whole dataset from .txt file

JUnit is something new for me and I'm testing my app like this:

@Before code...

@After code...

@Test test for data1

@Test test for data2...

@Test test for dataN

But I don't want my tests to take couple hundreds of lines when I'm testing the same method just for different parameters. I want to do something like this but I want to get results for each test

    @Test
public final void testAll(){

    String data = load from file
    String bool = load from file
    boolean expectedResult;
    if(bool.equals("T")
        expectedResult = true;
    else
        expectedResult = false;
    assertEquals(expectedResult, testedMethod(data);
}

With some kind of loop inside testAll() for all the data...

Aucun commentaire:

Enregistrer un commentaire