- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试在 Eclipse 中运行我的第一个 Spock 测试,但它不起作用。
我在我的 pom.xml 中添加了所有 Maven 依赖项和插件,但是当我使用 jUnit 运行我的测试时,有一个带有此警告消息的弹出窗口:“未找到 jUnit 测试”。
您是否已经看到过此类消息?
为了在 Eclipse 中运行 Spock 测试,必须完成哪些配置?
非常感谢。
最佳答案
它与运行 Junit 测试用例相同。
右键单击该类并作为 4Junit 测试运行器运行。请参阅下面的完整配置和运行 spock 测试。
使用 Eclipse、Gradle、Groovy 运行 Spock 框架:源代码 -
Krzysztof Goralski, blog
-Install Gradle Plugin, check it here
-Install Groovy-Eclipse for Juno or Indigo from Eclipse Marketplace (or maybe Groovy/Grails Tool Suite for Eclipse)
-Install Spock Plugin From Eclipse Marketplace if you want, check it here
-Import Project to Eclipse through Gradle Import
-Add these lines to build.gradle:
apply plugin: ‘groovy’
testCompile ‘org.spockframework:spock-spring:1.0-groovy-2.3’ (for Spring)
this is quite important, version can make some conflicts
-After this *.groovy and *.gradle files will problably looks different, Syntax colour highlightning etc. Remember that you can right click on for eg. build.gradle -> Open with -> Open With Minimalist gradle Editor etc.
-Probably you will need to make additional folder for *.groovy test files Create new *.groovy file, class
-Basic test example, extends Specification from Spock framework and needs specific Annotations when running with Spring
-Now you can run it with JUnit from Eclipse For integration tests you can’t use @RunWith(SpringJUnit4ClassRunner.class), and Context should looks like here @ContextConfiguration(locations = [ “/restTestContext.xml” ]) , not {} braces, but [ ]
-Spock can be used for Mocks too. Something like this: Subscriber subscriber1 = Mock() , subscriber1.isActive() >> true , So, remember >> operator for mocks.
关于groovy - 如何在 Eclipse 中运行 Spock 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10415171/
我是一名优秀的程序员,十分优秀!