无法使用Gradle运行Scalatest

编程入门 行业动态 更新时间:2024-10-25 06:28:18
本文介绍了无法使用Gradle运行Scalatest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 task scalaTest(dependsOn: testClasses) << { description = 'Runs Scalatest suite' ant.taskdef(name: 'scalatest', classname: 'org.scalatest.tools.ScalaTestAntTask', classpath: sourceSets.test.runtimeClasspath.asPath ) ant.scalatest(runpath: sourceSets.test.output.classesDir, haltonfailure: 'true', fork: 'false') { reporter(type: 'stdout') } }

我运行gradle scalaTest,我得到:

* What went wrong: Execution failed for task ':scalaTest'. > java.lang.NoClassDefFoundError: scala/reflect/ClassManifest$

我正在使用Scala 2.10.2和Gradle 1.7

I am using Scala 2.10.2 and Gradle 1.7

dependencies { compile 'org.scala-lang:scala-library:2.10.2' testCompile 'org.scalatest:scalatest:1.3' testCompile 'org.scalamock:scalamock_2.10:3.0.1' }

怎么了?

推荐答案

我不知道如何解决这个问题,但是我可以为您提供解决方法.用@RunWith(classOf[JUnitRunner])注释测试类,如下所示:

I do not know how to solve this one, but I can offer you a workaround. Annotate your test classes with @RunWith(classOf[JUnitRunner]), like this:

import org.scalatest.junit.JUnitRunner import org.junit.runner.RunWith @RunWith(classOf[JUnitRunner]) class MyTest extends FunSpec{ }

,然后gradle test应该可以工作.

我的依赖项:

compile "org.scala-lang:scala-library:2.10.1" testCompile "org.scalatest:scalatest_2.10:1.9.1"

更多推荐

无法使用Gradle运行Scalatest

本文发布于:2023-11-25 05:49:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1628565.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Gradle   Scalatest

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!