2

ant を使用してテストを実行するときに、いくつかの新しいコードが JUnit テストでうまく動作するように説得するのに苦労しています。

AWS SDK for Java を使用して AWS (Amazon Web Services) と対話するコードがいくつかあります。私の Junit テストで、この SDK 内の何かを参照するコードに出くわすと、テストは失敗します。ステップスルーすると、コード自体は正常に機能します。失敗しているのは、既存の、それ以外の場合は成功した Junit テストです。

-v オプションを使用してコマンドラインから ant を実行しました。AWS SDK for Java の jar ファイルがクラスパスに含まれていることがわかります。Ant と JUnit も含まれています。-v オプションは、失敗が actOnTestResult で報告されていることを示していますが、それはエラー自体が発生している場所ではありません。

ant -v の完全な出力は次のとおりです。

Apache Ant(TM) version 1.8.2 compiled on December 3 2011
Trying the default build file: build.xml
Buildfile: /home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/build.xml
Detected Java version: 1.6 in: /usr/lib/jvm/jdk1.6.0_32/jre

Detected OS: Linux

parsing buildfile /home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/build.xml with URI = file:/home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/build.xml

Project base dir set to: /home/tonyb1/Dev/Workspace/S3DataExtractionDeploy

parsing buildfile jar:file:/usr/share/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/usr/share/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file

Importing file /home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/lib/one-jar-ant-task.xml from /home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/build.xml

Overriding previous definition of reference to ant.projectHelper

parsing buildfile /home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/lib/one-jar-ant-task.xml with URI = file:/home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/lib/one-jar-ant-task.xml

Override ignored for property "one-jar.dist.dir"

Overriding previous definition of reference to ant.projectHelper

Build sequence for target(s) `junit' is [init, compile, junit]

Complete build sequence is [init, compile, junit, input-cmdlineargs, jar, onejar, run-cmdline, input-fileprops, run-hudson, help, clean, usage, input-eclipseargs, run-eclipse, ]


init:

 [echo] Creating build directories...

[mkdir] Skipping /home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/build because it already exists.

[mkdir] Skipping /home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/build/class because it already exists.

[mkdir] Skipping /home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/build/jar because it already exists.

[mkdir] Skipping /home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/dist because it already exists.


compile:

 [echo] Compiling source files...

[javac] /home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/src/AwsCredentials.properties skipped - don't know how to handle it

[javac] com/sportingindex/tradingservices/hadoop/aws/S3DataExtractionDeploy.java omitted as /home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/build/class/com/sportingindex/tradingservices/hadoop/aws/S3DataExtractionDeploy.class is up to date.

[javac] com/sportingindex/tradingservices/test/hadoop/aws/JUnit_S3DataExtractionDeploy.java omitted as /home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/build/class/com/sportingindex/tradingservices/test/hadoop/aws/JUnit_S3DataExtractionDeploy.class is up to date.


junit:

[junit] Implicitly adding /usr/share/ant/lib/junit.jar:/usr/share/java/ant-launcher-1.8.2.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-junit.jar:/usr/share/ant/lib/ant-junit4.jar to CLASSPATH

[junit] Executing '/usr/lib/jvm/jdk1.6.0_32/jre/bin/java' with arguments:

[junit] '-classpath'

[junit] '/home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/build/class:/home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/lib/aws-java-sdk-1.3.7.jar:/home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/lib/commons-codec-1.6.jar:/home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/lib/commons-collections-3.2.1.jar:/home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/lib/commons-logging-1.0.4.jar:/home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/lib/httpclient-4.1.3.jar:/home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/lib/httpcore-4.2.jar:/home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/lib/junit.jar:/home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/lib/one-jar-ant-task-0.97.jar:/usr/share/ant/lib/junit.jar:/usr/share/java/ant-launcher-1.8.2.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-junit.jar:/usr/share/ant/lib/ant-junit4.jar'

[junit] 'org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner'

[junit] 'com.sportingindex.tradingservices.test.hadoop.aws.JUnit_S3DataExtractionDeploy'

[junit] 'filtertrace=true'

[junit] 'haltOnError=false'

[junit] 'haltOnFailure=true'

[junit] 'formatter=org.apache.tools.ant.taskdefs.optional.junit.SummaryJUnitResultFormatter'

[junit] 'showoutput=false'

[junit] 'outputtoformatters=true'

[junit] 'logfailedtests=true'

[junit] 'logtestlistenerevents=false'

[junit] 'crashfile=/home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/junitvmwatcher8947588636768864827.properties'

[junit] 'propsfile=/home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/junit7746049445603740673.properties'

[junit]

[junit] The ' characters around the executable and arguments are

[junit] not part of the command.

[junit] Running com.sportingindex.tradingservices.test.hadoop.aws.JUnit_S3DataExtractionDeploy

[junit] Tests run: 4, Failures: 0, Errors: 4, Time elapsed: 0.756 sec


BUILD FAILED

/home/tonyb1/Dev/Workspace/S3DataExtractionDeploy/build.xml:218: Test com.sportingindex.tradingservices.test.hadoop.aws.JUnit_S3DataExtractionDeploy failed

at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.actOnTestResult(JUnitTask.java:1954)

at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:854)

at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeOrQueue(JUnitTask.java:1899)

at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:800)

at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)

at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)

at org.apache.tools.ant.Task.perform(Task.java:348)

at org.apache.tools.ant.Target.execute(Target.java:390)

at org.apache.tools.ant.Target.performTasks(Target.java:411)

at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)

at org.apache.tools.ant.Project.executeTarget(Project.java:1368)

at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)

at org.apache.tools.ant.Project.executeTargets(Project.java:1251)

at org.apache.tools.ant.Main.runBuild(Main.java:809)

at org.apache.tools.ant.Main.startAnt(Main.java:217)

at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)

at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)


Total time: 2 seconds

Eclipse を使用してテストを実行またはデバッグする場合は問題ありません。エラーが発生するのは、ant を使用してテストを実行したときだけです。

4

2 に答える 2