I tried to run the JUnit test, but it continues to fail - even if the code needs to pass the test. Any ideas why? I set the function, conversion coefficient and test
This is a test:
private static MathContext mc = new MathContext( 12, RoundingMode.HALF_EVEN ); public static final BigDecimal testValue = new BigDecimal( 123456.1234567 ); @Test public final void testconvertFathomToMetersDM3() { BigDecimal expectedResult = unitConverter.convertFathomToMetersDM3(testValue); assertTrue( expectedResult.equals( new BigDecimal( 1.234561234567E+21, mc ) ) ); }
This is the method that should perform the conversion:
private BigDecimal result; private static MathContext mc = new MathContext( 12, RoundingMode.HALF_EVEN ); public final BigDecimal convertMetersToFathomDM3(BigDecimal value) { result = value.divide( ConversionFactors.FATHOM_DMA3, mc ); return result; }
Here is the conversion factor I used:
public static final BigDecimal FATHOM_DMA3 = new BigDecimal( 1.875E+1 );
java junit
Rob willey
source share