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);
}
}
以上是我的测试用例。基于两种情况,我想执行上述一组测试方法。
例如:
- 在条件 X 上,仅应执行
checkInPathFolder()
、checkCustomObjectExists()
、runSwift()
。 - 在条件 Y 上,应执行
checkInPathFolder()
、runSwift()
、checkExceptionFolder()
。
最佳答案
使用JUnit 的assume
机制描述here .如果您想驱动这两个条件,您将需要使用 Theories
或 Parameterized
来使 JUnit
执行不止一次。
关于java - JUnit 有条件地运行测试方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16668430/