相关疑难解决方法(0)

TestNG能看到我的Spock(JUnit)测试结果吗?

需要让TestNG运行我的Spock测试,因为TestNG用于整个系统的其余部分.
由于TestNG支持运行JUnit测试,我试过这个:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="suiteTestName" verbose="1" junit="true">
    <test name="myTestName">
        <classes>
            <class name="mypackage.artifact.SomeArtifactSpecification" />
        </classes>
    </test>
</suite>
Run Code Online (Sandbox Code Playgroud)

所以这实际上完全运行了Groovy的'SomeArtifactSpecification'Spock单元测试.我可以从测试中看到一些I/O,但是因为我在Eclipse中运行,所以我使用调试器来验证所有测试是否正确执行.我的类路径上有TestNG-6.8.7和JUnit-4.10.问题是TestNG似乎并不知道它确实如此!这是最终输出:

===============================================
myTestName
Total tests run: 0, Failures: 0, Skips: 0
===============================================
Run Code Online (Sandbox Code Playgroud)

有谁知道是否有可能让TestNG识别这些测试?

其他详细信息 - 为Bounty添加

在下面的一条评论中,彼得表示这取决于TestNG正在做什么.我尽可能地调查了这一点.似乎Junit和TestNG都调用了Spock的Sputnik类第63行的'run'方法.但是,当直接从JUnit调用时,从JUnit4TestClassReference调用Sputnik.从TestNG调用时,从JUnitCore调用Sputnik.

所以问题仍然存在:如何让TestNG识别Spock的测试输出?如果我要长寿和繁荣,我真的需要知道!似乎答案可能是让TestNG与JUnit4TestClassReference一起运行,或者使用某种类型的聪明包装器来使TestNG这样做......

对于血淋淋的细节,我在下面发布了两个堆栈跟踪.第一个是从TestNG运行,它不起作用,第二个是直接运行Spock而没有TestNG.

来自TestNG的第一个堆栈跟踪:

org.testng.remote.RemoteTestNG at localhost:54288   
Thread [main] (Suspended (breakpoint at line 65 in ArtifactManagerSpecification))   
    ArtifactManagerSpecification.$spock_feature_0_0() line: 65  
    NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]  
    NativeMethodAccessorImpl.invoke(Object, Object[]) line: 57  
    DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43  
    Method.invoke(Object, Object...) line: 601  
    ReflectionUtil.invokeMethod(Object, Method, Object...) line: 138 …
Run Code Online (Sandbox Code Playgroud)

groovy junit testng unit-testing spock

5
推荐指数
1
解决办法
1201
查看次数

如何在Spock中运行一项特定规范?与GEB和Gradle一起使用

我正在结合使用gradle,geb和spock创建一个相当大的测试套件。Gradle显然正在构建和启动geb和spock,但是我认为spock是我可以控制和指定运行哪个Spec的地方。

我正在基于此启动器构建它。

https://github.com/AutomationSchool/geb-and-spock-automation-examples

如何将其设置为仅运行一个Spec?

groovy gradle spock geb

3
推荐指数
1
解决办法
88
查看次数

标签 统计

groovy ×2

spock ×2

geb ×1

gradle ×1

junit ×1

testng ×1

unit-testing ×1