junit测试可以在本地和jenkins运行,但不能运行在竹子上

我有1个测试用例在本地运行(在控制台的maven中以及直接从IDE中运行)以及我们的jenkins服务器中。

但是当我们在Bamboo中运行它时(我们将我们的构建迁移到Bamboo),我没有得到预期的断言结果。 测试期望针对无效输入抛出CommitException,例如负数。

测试输入引起异常的特殊情况是它是负值。

代码片段是:

@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();
}

任何可能导致错误的线索?

其他信息在本地和Bamboo中,使用maven 3(3.0.4 / 3.0.3)并使用JDK 1.7。 在Jenkins中使用Maven 2,但也使用JDK 1.7。

当它在竹子中失败时,显示的日志是:

[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)

链接地址: http://www.djcxy.com/p/63213.html

上一篇: junit test runs OK locally and in jenkins but not in bamboo

下一篇: Trigger a build in Bamboo from a Jenkins job