From my JUnit test I want to call this method, it lets me call it however even though it is supposed to cause an error it passes the test instead of failing.
public void handleErrors(String string, boolean b) {
System.out.println(string + ", " + b);
if(b == false){
collector.addError(new Throwable(string + ", " + b));
}
}
If I pass this in which should cause a failure in the test it should fail but it does not.
@Test
public void test() throws InterruptedException {
handleErrors("Button was found", false);
}
Why isn’t JUint reporting a failure?
EDIT:
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();
}
}
Fixed this. I did not move the
line.