Collections:
Run Sample Program with junit-4.*.jar
How to run sample program with junit-4.*.jar? I have Calculator.java and the JUnit test program, CalculatorTest.java ready.
✍: Guest
junit-4.13.2.jar is a JUnit 4 JAR library file.
It requires hamcrest-core-1.3.jar.
To run the JUnit test program, CalculatorTest.java, you need launch the org.junit.runner.JUnitCore class and specify the test program class as the parameter:
fyicenter> java -cp .;junit-4.13.2.jar;hamcrest-core-1.3.jar \
org.junit.runner.JUnitCore CalculatorTest
fyicenter> java -cp .:junit-4.13.2.jar:hamcrest-core-1.3.jar \
org.junit.runner.JUnitCore CalculatorTest
JUnit version 4.13.2
.E..E
Time: 0.019
There were 2 failures:
1) testFraction(CalculatorTest)
junit.framework.AssertionFailedError: expected:<5> but was:<4>
at junit.framework.Assert.fail(Assert.java:57)
at junit.framework.Assert.failNotEquals(Assert.java:329)
at junit.framework.Assert.assertEquals(Assert.java:78)
at junit.framework.Assert.assertEquals(Assert.java:234)
at junit.framework.Assert.assertEquals(Assert.java:241)
at junit.framework.TestCase.assertEquals(TestCase.java:384)
at CalculatorTest.testFraction(CalculatorTest.java:12)
2) testSubtraction(CalculatorTest)
java.lang.NumberFormatException: For input string: "10-1"
at java.base/jdk.internal.math.FloatingDecimal
.readJavaFormatString(FloatingDecimal.java:2054)
at java.base/jdk.internal.math.FloatingDecimal
.parseFloat(FloatingDecimal.java:122)
at java.base/java.lang.Float.parseFloat(Float.java:556)
at java.base/java.lang.Float.valueOf(Float.java:520)
at Calculator.evaluate(Calculator.java:6)
at CalculatorTest.testSubtraction(CalculatorTest.java:16)
FAILURES!!!
Tests run: 3, Failures: 2
The output shows that:
2025-04-03, 289🔥, 0💬
Popular Posts:
How to find out my browser's identification information? To help you to see your browser identificat...
How to access Response Status Code 400 as Success? My sampler failed, because the server returns the...
How to convert hexadecimal encoded data back to binary data (or Hex to Binary Decoding)? Hex to Bina...
How to convert hexadecimal encoded data back to binary data (or Hex to Binary Decoding)? Hex to Bina...
How to access Response Status Code 400 as Success? My sampler failed, because the server returns the...