Junit - Ant - Soap UI和数据文件

时间:2014-02-26 18:07:11

标签: ant junit soapui

我正在尝试运行一个基本的REST Web服务测试,从ANT中的JUnit调用Soap UI项目。

所有内容都正确编译并运行,但是当我尝试运行使用外部数据文件的测试时,我收到错误:

  

无法从C:\ soapTest \ atmTest3.csv获取资源:   java.util.zip.ZipException:打开zip文件时出错       [junit]无法从C:\ soapTest \ atmTest3.csv获取资源:

我已经搜索并看过其他有过课程问题的人,并试图只包括我认为我需要的东西。这就是我在build.xml中包含我的数据文件的方式

<path id ="test.input.dir" >
  <pathelement path="C:\soapTest\atmTest3.csv" />
</path>

<path id="classpath.junittest">
   <path refid="test.input.dir" /> 
   <path refid="jars.dir" />       
</path>

我的JUNIT方法非常基本

public void testRunner() throws Exception
{
    SoapUITestCaseRunner runner = new SoapUITestCaseRunner();
    runner.setProjectFile("C:/soapTest/ATM-Locator-soapui-project.xml");
    runner.run();
}

有没有人成功使用外部数据源文件并在JUNIT中运行?

有替代方案吗?

------------------ ANT输出如下-------------------

Building in workspace C:\JENKINS_PROJECTS\workspace\JUNIT_Test
[JUNIT_Test] $ cmd.exe /C '"C:\apache-ant-1.9.3\bin\ant.bat -D-Verbose="" -D-Debug="" && exit %%ERRORLEVEL%%"'
Buildfile: C:\JENKINS_PROJECTS\workspace\JUNIT_Test\build.xml
     [echo] Apache Ant version is Apache Ant(TM) version 1.9.3 compiled on December 23 2013 
     [echo] Apache basedir is C:\JENKINS_PROJECTS\workspace\JUNIT_Test 

compile:
    [javac] Compiling 2 source files to C:\JENKINS_PROJECTS\workspace\JUNIT_Test\classes

compile-test:
    [javac] Compiling 6 source files to C:\JENKINS_PROJECTS\workspace\JUNIT_Test\classes

test:
    [junit] Running com.JUnit.AllTests
    [junit] Testsuite: com.JUnit.AllTests
Unable to obtain resource from C:\soapTest\atmTest3.csv: java.util.zip.ZipException: error in opening zip file
    [junit] Unable to obtain resource from C:\soapTest\atmTest3.csv: 
    [junit] java.util.zip.ZipException: error in opening zip file
    [junit]     at java.util.zip.ZipFile.open(Native Method)
    [junit]     at java.util.zip.ZipFile.<init>(Unknown Source)
    [junit]     at java.util.jar.JarFile.<init>(Unknown Source)
    [junit]     at java.util.jar.JarFile.<init>(Unknown Source)
    [junit]     at org.apache.tools.ant.AntClassLoader.getResourceURL(AntClassLoader.java:1006)
    [junit]     at org.apache.tools.ant.AntClassLoader.getResource(AntClassLoader.java:887)
    [junit]     at org.apache.log4j.helpers.Loader.getResource(Loader.java:96)
    [junit]     at org.apache.log4j.LogManager.<clinit>(LogManager.java:103)
    [junit]     at org.apache.log4j.Logger.getLogger(Logger.java:117)
    [junit]     at com.eviware.soapui.SoapUI.<clinit>(SoapUI.java:135)
    [junit]     at com.eviware.soapui.tools.SoapUITestCaseRunner.<clinit>(SoapUITestCaseRunner.java:79)
    [junit]     at com.util.ParameterATM_Test.testRunner(Unknown Source)
    [junit]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [junit]     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    [junit]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    [junit]     at java.lang.reflect.Method.invoke(Unknown Source)
    [junit]     at junit.framework.TestCase.runTest(TestCase.java:168)
    [junit]     at junit.framework.TestCase.runBare(TestCase.java:134)
    [junit]     at junit.framework.TestResult$1.protect(TestResult.java:110)
    [junit]     at junit.framework.TestResult.runProtected(TestResult.java:128)
    [junit]     at junit.framework.TestResult.run(TestResult.java:113)
    [junit]     at junit.framework.TestCase.run(TestCase.java:124)
    [junit]     at junit.framework.TestSuite.runTest(TestSuite.java:243)
    [junit]     at junit.framework.TestSuite.run(TestSuite.java:238)
    [junit]     at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
    [junit]     at org.junit.runners.Suite.runChild(Suite.java:128)
    [junit]     at org.junit.runners.Suite.runChild(Suite.java:24)
    [junit]     at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    [junit]     at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    [junit]     at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    [junit]     at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    [junit]     at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    [junit]     at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    [junit]     at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:39)
    [junit]     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:532)
    [junit]     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeInVM(JUnitTask.java:1425)
    [junit]     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:852)
    [junit]     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeOrQueue(JUnitTask.java:1904)
    [junit]     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:804)
    [junit]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    [junit]     at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    [junit]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    [junit]     at java.lang.reflect.Method.invoke(Unknown Source)
    [junit]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    [junit]     at org.apache.tools.ant.Task.perform(Task.java:348)
    [junit]     at org.apache.tools.ant.Target.execute(Target.java:435)
    [junit]     at org.apache.tools.ant.Target.performTasks(Target.java:456)
    [junit]     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
    [junit]     at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
    [junit]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    [junit]     at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
    [junit]     at org.apache.tools.ant.Main.runBuild(Main.java:851)
    [junit]     at org.apache.tools.ant.Main.startAnt(Main.java:235)
    [junit]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
    [junit]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

0 个答案:

没有答案