Search code examples
javanetbeanstestngdataprovider

Testng marked a test as success when it should fail


I have test code as below. test1 passes the test but test2 failed when I expect both to fail. Can anyone please explain why this happens?

@Test(dataProvider="prov")
public void test1(int x, int y){
    System.out.println("x=" + x + ", y=" + y);
    assertEquals(x + y, 3);
}

@Test(dataProvider="prov")
public void test2(int x, int y){
    System.out.println("x=" + x + ", y=" + y);
    assertEquals(x + y, 7);
}

@DataProvider
public Object[][] prov(){
    return new Object[][]{
        {1,2},
        {3,4}
    };
}

Solution

  • Bingo! This is a netbeans bug. In command line, both tests failed.

    Off to report the bug now...