0

我有一个简单的 groovy 项目,我正在尝试运行一个没有的 Tmar 测试。这是我的项目结构和 Tmar 给出的堆栈跟踪的副本。

项目结构

以及测试执行的堆栈跟踪:

Start test
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.701 sec <<< FAILURE! - in org.dealus.MowItTest
test(org.dealus.MowItTest)  Time elapsed: 0.14 sec  <<< ERROR!
java.io.FileNotFoundException: D:\Dev\EclipseMarsWorkspace\mowit\target\tmar-test-results\MowItTest.test
        at org.codehaus.groovy.runtime.ResourceGroovyMethods.checkDir(ResourceGroovyMethods.java:1043)
        at org.codehaus.groovy.runtime.ResourceGroovyMethods.eachFile(ResourceGroovyMethods.java:1062)
        at org.codehaus.groovy.runtime.ResourceGroovyMethods.eachFile(ResourceGroovyMethods.java:1088)
        at org.codehaus.groovy.runtime.dgm$936.invoke(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
        at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
        at org.jspresso.contrib.tmar.report.TmarReport.generateSingleReport(TmarReport.groovy:1275)
        at org.jspresso.contrib.tmar.report.TmarReport$generateSingleReport.call(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:141)
        at org.jspresso.contrib.tmar.core.TmarBaseJUnitTestNG.getData(TmarBaseJUnitTestNG.groovy:30)
        at org.jspresso.contrib.tmar.core.TmarBaseJUnitTestNG$getData.callCurrent(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
        at org.dealus.MowItTest.test(MowItTest.groovy:12)


Results :

Tests in error:
  MowItTest.test:12->TmarBaseJUnitTestNG.getData:30 » FileNotFound D:\Dev\Eclips...

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

tmar 测试描述文件:

MowItTest

/each
[ Result ? |  
| Test ok  |  

这是基本代码:

package org.dealus

import org.jspresso.contrib.tmar.core.Tmar4JUnit;
import org.junit.Assert;
import org.junit.Test

class MowItTest extends Tmar4JUnit {

    @Test
    void test() {
        println "Start test"
        def testTmar = getData('test')
        eachIteration(testTmar) { tmar ->
            tmar.result = "Test ok"
        }
        println "Test complete"
    }
}
4

2 回答 2

0

我认为XML应该是这样的

   <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <TMAR>
        <CONFIG>
            <PROJECT name="Tmar sample project"/>
            <LOGO name="tmar-with-name-big.png"/>
            <DESCRIPTION_DIRECTORY name="src/test/resources/tmar/descriptions" type="file"/>
            <WORKING_DIRECTORY name="src/test/resources/tmar/working" type="file"/>
            <RESULT_DIRECTORY name="target/tmar-test-results"/>
            <REPORT_DIRECTORY name="target/tmar-test-report"/>
            <SRC_GOOGLE_GRAPH name="https://www.google.com/jsapi"/>
            <SHORTCUT name="WIKIPEDIA" value="http://en.wikipedia.org/wiki/"/>
        </CONFIG>
    </TMAR>

这是github链接:https ://github.com/jspresso/tmar-sample/blob/master/src/test/resources/tmar/tmar.config

您缺少 WORKING_DIRECTORY。

于 2015-12-14T16:58:22.393 回答
0

您的 Tmar 项目还可以,但是我对其进行了测试,发现 Tmar 和您在 pom 文件中引用的 groovy 版本 2.4.4 存在问题。降级到 2.3.1,它应该可以工作

于 2015-12-15T22:08:00.427 回答