junit测试在本地和jenkins运行,但不是竹子

时间:2015-03-24 17:09:26

标签: java junit bamboo

我有一个测试用例在本地运行(在控制台和直接从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();
}

有什么可能导致错误的线索?

其他信息 在本地和竹子中,使用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)

0 个答案:

没有答案