Error Report Not display even condition is fail | Selenium Forum
M
Posted on 29/04/2016
Hi,
Please help me i am try to implement Assertion feature and i failed the condition.With the help of Error Collector class it continue to move ahead to execute the message but in Junit it does not print result failure.
So please suggest me where i am wrong.....

Below is my Code and also attached the screenshot :-


package junit;
import org.junit.Assert;
import org.junit.Test;
import org.junit.rules.ErrorCollector;

public class Assertion {

ErrorCollector error1 = new ErrorCollector();
@Test
public void assertion(){

int expected_result=100;
int acctual_result=101;

try{
Assert.assertEquals(expected_result, acctual_result);
}catch(Throwable t){
System.out.println(t.getMessage());
System.out.println("Operatiom is sucessfull");
error1.addError(t);


}

}}

M
Replied on 29/04/2016

Hi Any Update.. Please reply on it. I m waiting for that. Responsive image


M
Replied on 29/04/2016

sorry for the delay

if you to print stack trace



import org.junit.Assert;
import org.junit.Test;
import org.junit.rules.ErrorCollector;

public class Assertion {

ErrorCollector error1 = new ErrorCollector();

@Test
public void assertion() {

int expected_result = 100;
int acctual_result = 101;

try {
Assert.assertEquals(expected_result, acctual_result);
} catch (Exception t) {
t.printStackTrace();
System.out.println("Operatiom is sucessfull");
error1.addError(t);

}

}
}