从我的 JUnit 测试中我想调用这个方法,它允许我调用它,但是即使它应该导致错误它通过测试而不是失败。
public void handleErrors(String string, boolean b) {
System.out.println(string + ", " + b);
if(b == false){
collector.addError(new Throwable(string + ", " + b));
}
}
如果我通过这个应该会导致测试失败,它应该会失败,但不会。
@Test
public void test() throws InterruptedException {
handleErrors("Button was found", false);
}
为什么 JUint 不报告失败?
编辑:
package com.selenium.tests;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.openqa.selenium.By;
import org.junit.rules.ErrorCollector;
import com.selenium.AbstractScreenTest;
public class test1 extends AbstractScreenTest{
@Rule
public ErrorCollector collector= new ErrorCollector();
@Before
public void initialize() {
createTest();
}
@Test
public void test() throws InterruptedException {
handleErrors("Button was found", false);
}
public void handleErrors(String string, boolean b) {
System.out.println(string + ", " + b);
if(b == false){
collector.addError(new Throwable(string + ", " + b));
}
}
@After
public void tearDown(){
closeTest();
}
}