gpt4 book ai didi

java - JUnit 有条件地运行测试方法

转载 作者:行者123 更新时间:2023-11-29 03:33:36 25 4
gpt4 key购买 nike

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);
}
}

以上是我的测试用例。基于两种情况,我想执行上述一组测试方法。

例如:

  1. 在条件 X 上,仅应执行 checkInPathFolder()checkCustomObjectExists()runSwift()
  2. 在条件 Y 上,应执行 checkInPathFolder()runSwift()checkExceptionFolder()

最佳答案

使用JUnit 的assume 机制描述here .如果您想驱动这两个条件,您将需要使用 TheoriesParameterized 来使 JUnit 执行不止一次。

关于java - JUnit 有条件地运行测试方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16668430/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com