0

I have 1 test case which is running OK locally (both in maven from console and directly from the IDE) and in our jenkins server.

But when we run it in Bamboo (we are migrating our builds to Bamboo) I am not getting the expected assertion result. The test expect a CommitException to be thrown for invalid input, e.g. negative amount.

The special thing with the test input causing the anomaly is that it is a negative value.

Code snippet is:

@SuppressWarnings("unused")
private static Object[] randomInvalidAmounts() {
    //The test parameters are shortened to the specific one causing the error.
    return $(new DkkAmount(-200.0));
}

@Test(expected = CommitException.class)
@Parameters(method = "randomInvalidAmounts")
public void ERROR_WHEN_FIELD_INPUT_FOR_VAULT50_IS_NOT_VALID(DkkAmount amount)
        throws PageIntializationFailedException,
        ServiceException, ResourceException, CommitException {
    //Some init methods to mock and get some private members
    validateAndCreatePage();

    getModelAndViewValues();

    view.getVault50().setValue(amount);

    //This is the method that actually fires up the flow that should cause the CommitException.
    ((FieldGroup) ReflectionTestUtils.getField(presenter, "fieldGroup")).commit();
}

Any clue on what can be causing the error?

Additional Info Locally and in Bamboo, maven 3 is used (3.0.4 / 3.0.3) and using JDK 1.7. In Jenkins Maven 2 is used but is also using JDK 1.7.

When it fails in bamboo, the log shown is:

[0] -200.0 DKK (ERROR_WHEN_FIELD_INPUT_FOR_VAULT1_IS_NOT_VALID)(com.package.TestClass) Time elapsed: 0.025 sec <<< FAILURE! build 24-Mar-2015 16:31:49 java.lang.AssertionError: Expected exception: com.vaadin.data.fieldgroup.FieldGroup$CommitException build 24-Mar-2015 16:31:49 at org.junit.internal.runners.statements.ExpectException.evaluate(ExpectException.java:32) build 24-Mar-2015 16:31:49 at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) build 24-Mar-2015 16:31:49 at junitparams.internal.ParameterisedTestMethodRunner.runMethodInvoker(ParameterisedTestMethodRunner.java:47) build 24-Mar-2015 16:31:49 at junitparams.internal.ParameterisedTestMethodRunner.runTestMethod(ParameterisedTestMethodRunner.java:40) build 24-Mar-2015 16:31:49 at junitparams.internal.ParameterisedTestClassRunner.runParameterisedTest(ParameterisedTestClassRunner.java:147) build 24-Mar-2015 16:31:49 at junitparams.JUnitParamsRunner.runChild(JUnitParamsRunner.java:414) build 24-Mar-2015 16:31:49 at junitparams.JUnitParamsRunner.runChild(JUnitParamsRunner.java:385) build 24-Mar-2015 16:31:49 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) build 24-Mar-2015 16:31:49 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) build 24-Mar-2015 16:31:49 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) build 24-Mar-2015 16:31:49 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) build 24-Mar-2015 16:31:49 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) build 24-Mar-2015 16:31:49 at org.junit.runners.ParentRunner.run(ParentRunner.java:309) build 24-Mar-2015 16:31:49 at org.junit.runners.Suite.runChild(Suite.java:127) build 24-Mar-2015 16:31:49 at org.junit.runners.Suite.runChild(Suite.java:26) build 24-Mar-2015 16:31:49 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) build 24-Mar-2015 16:31:49 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) build 24-Mar-2015 16:31:49 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) build 24-Mar-2015 16:31:49 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) build 24-Mar-2015 16:31:49 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) build 24-Mar-2015 16:31:49 at org.junit.runners.ParentRunner.run(ParentRunner.java:309) build 24-Mar-2015 16:31:49 at org.junit.runner.JUnitCore.run(JUnitCore.java:160) build 24-Mar-2015 16:31:49 at org.junit.runner.JUnitCore.run(JUnitCore.java:138) build 24-Mar-2015 16:31:49 at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.createRequestAndRun(JUnitCoreWrapper.java:113) build 24-Mar-2015 16:31:49 at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.executeEager(JUnitCoreWrapper.java:85) build 24-Mar-2015 16:31:49 at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:54) build 24-Mar-2015 16:31:49 at org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:134) build 24-Mar-2015 16:31:49 at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200) build 24-Mar-2015 16:31:49 at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153) build 24-Mar-2015 16:31:49 at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)

Ian
  • 1
  • 2
  • What do the logs say? Bamboo logs? your app's log? your test suite logs? As it stands, it's hard (impossible?) to know since you are not saying what configuration differences there may be between Jenkins and Bamboo (i.e. are they using the same Java version?) - Please refer to the [ask] page for hints on how to improve the question and get rocking answers from the community – blurfus Mar 24 '15 at 17:37
  • Hi @ochi, I added some more info. Sorry if the formulation was not good enough. – Ian Mar 24 '15 at 18:47
  • You have a `$` sign in front of your return statement (I.e. `return $(new DkkAmount(-200.0));` is that correct? looks like an error... can you confirm? – blurfus Mar 24 '15 at 20:21
  • The `$` is from JUnitParamsRunner package. I'm doing [parameterised test](https://github.com/Pragmatists/JUnitParams/wiki/Quickstart), so that was on purpose. I'm actually thinking that the problem is more about the underlying OS or processor (which can interpret negative BigDecimal - which DkkAmount is subclass of - wrongly?), but I want to hear from the stackoverflow community if there is a much simpler explanation. – Ian Mar 25 '15 at 09:34
  • Are you subclassing `BigDecimal` only to have your own `DkkAmount` class? - maybe there is a good reason for it I suppose. As long as you are not overriding any methods, I don't see an issue. – blurfus Mar 25 '15 at 15:56

0 Answers0