voldy
voldy

Reputation: 387

JUnit running test methods conditionally

import static org.junit.Assert.assertTrue;

import org.junit.Before;
import org.junit.Test;
public class SwiftTest {
    SwiftUtil swiftUtil = new SwiftUtil();
    boolean result;
    @Test
    public void checkInPathFolder()
    {
        result = swiftUtil.checkInPathFolder();
        assertTrue(result);
    }
    @Test
    public void checkCustomObjectExists()
    {
        result=swiftUtil.validateWFId();
        assertTrue(result);
    }
    @Test
    public void runSwift()
    {
        result=swiftUtil.runSwiftBatch();
        assertTrue(result);
    }
    @Test
    public void checkTreatedFolder()
    {
        result=swiftUtil.checkTreatedFolder();
        assertTrue(result);
    }
    @Test
    public void checkExceptionFolder()
    {
        result=swiftUtil.checkExceptionFolder();
        assertTrue(result);
    }
}

Above is my Test case. based on two cases i want to execute set of above test methods.

For eg:

  1. On Condition X, only checkInPathFolder(), checkCustomObjectExists(), runSwift() should be executed.
  2. On Condition Y, checkInPathFolder(), runSwift(), checkExceptionFolder() should be executed.

Upvotes: 1

Views: 7055

Answers (1)

John B
John B

Reputation: 32949

Use JUnit's assume mechanism described here. You will need to use either Theories of Parameterized to cause JUnit to execute more than once if you want to drive those two conditions.

Upvotes: 4

Related Questions