【发布时间】:2015-05-27 12:00:30
【问题描述】:
我正在为一个 java 应用程序编写 Junit 测试用例。 如果我单独运行测试功能,它运行良好。 当我尝试将它们一起运行时,它无法正常运行
这是 JUnit 代码
public class CultureMachineTestCases{
CultureMachineAssignment testObj=new CultureMachineAssignment ();
HashSet<String> result =new HashSet<String>();
String answer,answer1;
int flagVal;
@Before
public void init() throws IOException{
testObj.insertDataIntoSet();
testObj.addKeywords("video1");
}
@Test
public void testVideo() throws IOException {
result=testObj.search("abcd");
answer=result.toString();
answer1=answer.replaceAll("[^a-z0-9]","");
assertEquals("video1", answer1);
}
@Before
public void initMethod() throws IOException{
testObj.insertDataIntoSet();
testObj.addKeywords("video2");
}
@Test
public void testLenth() throws IOException{
flagVal=testObj.flag;
assertEquals(1, flagVal);
}
}
这里的标志在 CultureMachineAssignment 文件中设置为 1。 谁能告诉我我需要做什么,以便我可以一起运行测试文件中的所有功能
【问题讨论】:
标签: java eclipse unit-testing junit