Reputation: 63
I have run a test using JUnit in NetBeans, and I get this test results :
and this is the output message :
Tests run: 0, Failures: 0, Errors: 2, Time elapsed: 0,336 sec
------------- Standard Output --------------- avant tout après tout ------------- ---------------- --------------- Testcase: calculette.calculMethodeTest: Caused an ERROR Illegal local variable table length 24 in method calculette.Calculette.main([Ljava/lang/String;)V java.lang.ClassFormatError: Illegal local variable table length 24 in method calculette.Calculette.main([Ljava/lang/String;)V at calculette.calculMethodeTest.setUpClass(calculMethodeTest.java:24)
Testcase: calculette.calculMethodeTest: Caused an ERROR null java.lang.NullPointerException at calculette.calculMethodeTest.tearDownClass(calculMethodeTest.java:30)
Test calculette.calculMethodeTest FAILED test-report: C:\Users\Aimad\Documents\NetBeansProjects\Calculette\nbproject\build-impl.xml:933: Some tests failed; see details above. BUILD FAILED (total time: 12 seconds)
what are these errors means ?
this is the test methods :
**
* Test of main method, of class Calculette.
*/
@Test
public void testMain() {
System.out.println("main");
String[] args = null;
Calculette.main(args);
}
/**
* Test of multiplication method, of class Calculette.
*/
@Test
public void testMultiplication() {
System.out.println("multiplication");
double a = 2.0;
double b = -5.0;
Calculette instance = new Calculette();
double expResult = -10.0;
double result = instance.multiplication(a, b);
assertEquals(expResult, result, 0.0);
}
/**
* Test of division method, of class Calculette.
*/
@Test (expected = DivisionSurZeroException.class)
public void testDivision() {
System.out.println("division");
double a = 0.0;
double b = 0.0;
Calculette instance = new Calculette();
double expResult = a/b;
double result = instance.division(a, b);
assertEquals(expResult, result, 0.0);
a = 10;
b = 10;
expResult = a/b;
assertEquals(expResult, result, 0.0);
a = 10;
b = 0;
expResult = a/b;
assertEquals(expResult, result, 0.0);
a = 10;
b = -10;
expResult = a/b;
assertEquals(expResult, result, 0.0);
a = 0;
b = 10;
expResult = a/b;
assertEquals(expResult, result, 0.0);
a = 0;
b = -10;
expResult = a/b;
assertEquals(expResult, result, 0.0);
a = -10;
b = 10;
expResult = a/b;
assertEquals(expResult, result, 0.0);
a = -10;
b = 0;
expResult = a/b;
assertEquals(expResult, result, 0.0);
a = -10;
b = -10;
expResult = a/b;
assertEquals(expResult, result, 0.0);
}
/**
* Test of addition method, of class Calculette.
*/
@Test
public void testAddition() {
System.out.println("addition");
double a = -10.1;
double b = -70.0;
Calculette instance = new Calculette();
double expResult = a + b;
double result = instance.addition(a, b);
assertEquals(expResult, result, 0.0);
}
/**
* Test of soustraction method, of class Calculette.
*/
@Test
public void testSoustraction() {
System.out.println("soustraction");
double a = -60.5;
double b = 5.0;
Calculette instance = new Calculette();
double expResult = a - b;
double result = instance.soustraction(a, b);
assertEquals(expResult, result, 0.0);
}
And this is the original methods :
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new Calculette().setVisible(true);
}
});
}
@Override
public double multiplication(double a, double b) {
return a*b;
}
@Override
public double division(double a, double b) {
if(b == 0) throw new DivisionSurZeroException();
else return a/b;
}
@Override
public double addition(double a, double b) {
return a + b;
}
@Override
public double soustraction(double a, double b) {
return a-b;
}
Upvotes: 0
Views: 1129
Reputation: 33351
While it is a good call that 0.0
is not a very meaningful delta for testing double mathematics (small, positive, non-zero number is what you typically want, take a look here for some discussion about what the delta is), I don't believe that is to blame for the error. That should just result in unexpectedly failing tests.
This issue seems to come up related changes to the Byte Code Verifier, in Java 7. I appears that you can fix the issue by passing the argument
-XX:-UseSplitVerifier
(You can refer to this NetBeans resource If you need help on how to set these args)
Upvotes: 0