Skip to content

Instantly share code, notes, and snippets.

@jasonrobot
Created May 15, 2018 23:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonrobot/f395a0fe476baa07bc4c79f6391ac3f3 to your computer and use it in GitHub Desktop.
Save jasonrobot/f395a0fe476baa07bc4c79f6391ac3f3 to your computer and use it in GitHub Desktop.
Z runs, Y runs and fails, X skips, W goes anyways, but after Y.
public class TestTestDeps
{
@Test(alwaysRun = true)
public void testZ()
{
System.out.println("z is running");
assertEquals(1, 1);
}
@Test(dependsOnMethods = "testZ")
public void testY()
{
System.out.println("y is running");
assertEquals(1, 2);
}
@Test(dependsOnMethods = "testY")
public void testX()
{
System.out.println("x is running");
assertEquals(2, 2);
}
@Test(dependsOnMethods = "testY", alwaysRun = true)
public void testW()
{
System.out.println("w is running");
assertEquals(3, 3);
}
// Results:
//
// z is running
// y is running
//
// java.lang.AssertionError: expected [2] but found [1]
// Expected :2
// Actual :1
// <Click to see difference>
//
// w is running
//
// Test ignored. <--- That's testX getting skipped
//
// ===============================================
// Default Suite
// Total tests run: 4, Failures: 1, Skips: 1
// ===============================================
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment