S
swetha
I have the following test case for a method someMeth(int ID) in class
classA():
@Test(expected=java.sql.BatchUpdateException.class)
public void insertValues()
{
classA var = new classA();
var.someMeth(1);
}
This method is expected to throw a BatchUpdateException for the given
output. When the test is run, the java.sql.BatchUpdateException is
thrown and shows up in the stack trace. But the test case fails with
caused an error
Expected exception: java.sql.BatchUpdateException
java.lang.AssertionError
at
org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:
100)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
at
org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:
87)
....................
Any idea why this is happening and why even though the stack trace
shows the error being thrown, it still results in an error when the
test runs?
I've also tried the following but with no difference in results:
@Test(expected=java.sql.BatchUpdateException.class)
public void someMethTester()
{
classA var = new classA();
int count = var.someMeth(1);
assertEquals("Inserting values with invalid ID case failed", 0,
count);
}
If I remove the (expected=...) part from the above and run the test
then the test passes because my assertEquals returns true but I still
have the BatchUpdateException in the stack trace.
Any inputs will be appreciated.
Thanks
classA():
@Test(expected=java.sql.BatchUpdateException.class)
public void insertValues()
{
classA var = new classA();
var.someMeth(1);
}
This method is expected to throw a BatchUpdateException for the given
output. When the test is run, the java.sql.BatchUpdateException is
thrown and shows up in the stack trace. But the test case fails with
caused an error
Expected exception: java.sql.BatchUpdateException
java.lang.AssertionError
at
org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:
100)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
at
org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:
87)
....................
Any idea why this is happening and why even though the stack trace
shows the error being thrown, it still results in an error when the
test runs?
I've also tried the following but with no difference in results:
@Test(expected=java.sql.BatchUpdateException.class)
public void someMethTester()
{
classA var = new classA();
int count = var.someMeth(1);
assertEquals("Inserting values with invalid ID case failed", 0,
count);
}
If I remove the (expected=...) part from the above and run the test
then the test passes because my assertEquals returns true but I still
have the BatchUpdateException in the stack trace.
Any inputs will be appreciated.
Thanks