Can't get uTest to see my tests

I am trying to get uTest to work with ScalaJS and SBT. SBT compiles files and uTest works, but it just ignores my tests. Try so that I cannot find the difference between my code and sample tutorials.

build.sbt:

enablePlugins(ScalaJSPlugin) name := "Scala.js Stuff" scalaVersion := "2.11.5" // or any other Scala version >= 2.10.2 scalaJSStage in Global := FastOptStage libraryDependencies += "com.lihaoyi" %% "utest" % "0.3.0" testFrameworks += new TestFramework("utest.runner.Framework") 

Src / test / scala / com / mysite / jovian / GeometryTest.scala:

 package com.mysite.jovian import utest._ object GeometryTest extends TestSuite { def tests = TestSuite { 'addPoints { val p: Point = new Point(3,4) val q: Point = new Point(4,3) val expected: Point = new Point(8,8) assert(p.plus(q).equals(expected)) throw new Exception("foo") } 'fail { assert(1==2) } } } 

Conclusion:

 > reload [info] Loading project definition from /Users/me/Dropbox (Personal)/mysite/flocks/project [info] Set current project to Scala.js Stuff (in build file:/Users/me/Dropbox%20(Personal)/mysite/flocks/) > test [success] Total time: 1 s, completed Mar 6, 2015 7:01:41 AM > test-only -- com.mysite.jovian.GeometryTest [info] Passed: Total 0, Failed 0, Errors 0, Passed 0 [info] No tests to run for test:testOnly [success] Total time: 1 s, completed Mar 6, 2015 7:01:49 AM 

If I introduce a syntax error, the sbt test sees it:

 > test [info] Compiling 1 Scala source to /Users/me/Dropbox (Personal)/mysite/flocks/target/scala-2.11/test-classes... [error] /Users/me/Dropbox (Personal)/mysite/flocks/src/test/scala/com/mysite/jovian/GeometryTest.scala:21: not found: value blablablablabla [error] blablablablabla [error] ^ [error] one error found [error] (test:compile) Compilation failed [error] Total time: 1 s, completed Mar 6, 2015 7:03:54 AM 

So, he definitely sees the code, it just doesn't seem that the β€œtests” contain any tests.

Otherwise, in non-test code SBT + ScalaJS works fine ...

Thanks for any help, I am puzzled.

+5
source share
1 answer

Your error is dependent on uTest:

 libraryDependencies += "com.lihaoyi" %% "utest" % "0.3.0" 

This is a JVM dependency. To use the Scala.js-enabled dependency, use %%% instead of %% , for example:

 libraryDependencies += "com.lihaoyi" %%% "utest" % "0.3.0" 

Also, you probably want this dependency only in the test configuration, so add % "test" a to the end:

 libraryDependencies += "com.lihaoyi" %%% "utest" % "0.3.0" % "test" 
+7
source

Source: https://habr.com/ru/post/1214821/


All Articles