Tor*_*ten 12 groovy intellij-idea spock
我尝试将groovy测试嵌入到java项目中.我从spock示例开始 - https://github.com/spockframework/spock-example
示例是通过运行maven目标测试来编译和执行,但如果我尝试在intellij idea下运行测试(在测试方法下使用ctrl + F10),则会因类路径错误而失败.
运行Spock的HelloSpockSpec.length和他朋友的名字时出错:模块'spock-example'中找不到类'HelloSpockSpec'
我尝试应用IntelliJ + Groovy + Spock的建议,但它没有帮助.
tim*_*tes 25
不要忘记在IntelliJ中将文件夹标记为"测试源"
然后它应该按预期工作:-)
Intellij 可以根据您的 pom.xml 自动将 groovy 源添加为源目录。将 build-helper-maven-plugin 配置添加到plugins指定${basedir}/src/test/groovy为源目录下的 maven pom 中:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-groovy-test-source</id>
<phase>test</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/src/test/groovy</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9598 次 |
| 最近记录: |