为什么添加“待处理”会导致破坏我的 Scala 测试?

发布于 2024-12-04 23:22:52 字数 3757 浏览 4 评论 0原文

下面的注释行破坏了我的测试,

import org.scalatest.WordSpec

class LSESuite extends WordSpec {

  "An LSE market" should {
    "round values" in  {
      val lse = new LSE {
      }
      assert(lse.getMarketName === "LSE")
      //"min tick size" is (pending)
    }
  }
}

我收到以下错误“一个 it 子句可能不会出现在另一个 it 子句中”,但我不确定如何解释。编辑堆栈跟踪:

org.scalatest.TestRegistrationClosedException: An it clause may not appear inside another it clause.
    at org.scalatest.SuperEngine.registerTest(Engine.scala:406)
    at org.scalatest.WordSpec$class.org$scalatest$WordSpec$$registerTestToRun(WordSpec.scala:1643)
    at org.scalatest.WordSpec$WordSpecStringWrapper.is(WordSpec.scala:1823)


    at org.scalatest.WordSpec$$anonfun$runTests$1.apply(WordSpec.scala:2232)
    at org.scalatest.WordSpec$$anonfun$runTests$1.apply(WordSpec.scala:2232)
    at org.scalatest.SuperEngine$$anonfun$org$scalatest$SuperEngine$$runTestsInBranch$1.apply(Engine.scala:226)
    at org.scalatest.SuperEngine$$anonfun$org$scalatest$SuperEngine$$runTestsInBranch$1.apply(Engine.scala:215)
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
    at scala.collection.immutable.List.foreach(List.scala:45)
    at org.scalatest.SuperEngine.org$scalatest$SuperEngine$$runTestsInBranch(Engine.scala:215)
    at org.scalatest.SuperEngine$$anonfun$org$scalatest$SuperEngine$$runTestsInBranch$1.apply(Engine.scala:231)
    at org.scalatest.SuperEngine$$anonfun$org$scalatest$SuperEngine$$runTestsInBranch$1.apply(Engine.scala:215)
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
    at scala.collection.immutable.List.foreach(List.scala:45)
    at org.scalatest.SuperEngine.org$scalatest$SuperEngine$$runTestsInBranch(Engine.scala:215)
    at org.scalatest.SuperEngine.runTestsImpl(Engine.scala:282)
    at org.scalatest.WordSpec$class.runTests(WordSpec.scala:2232)
    at org.scalatest.Suite$class.run(Suite.scala:2286)
    at org.scalatest.WordSpec$$anonfun$run$1.apply(WordSpec.scala:2279)
    at org.scalatest.WordSpec$$anonfun$run$1.apply(WordSpec.scala:2279)
    at org.scalatest.SuperEngine.runImpl(Engine.scala:318)
    at org.scalatest.WordSpec$class.run(WordSpec.scala:2279)
    at org.scalatest.tools.SuiteRunner.run(SuiteRunner.scala:59)
    at org.scalatest.tools.Runner$$anonfun$doRunRunRunDaDoRunRun$3.apply(Runner.scala:1517)
    at org.scalatest.tools.Runner$$anonfun$doRunRunRunDaDoRunRun$3.apply(Runner.scala:1514)
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
    at scala.collection.immutable.List.foreach(List.scala:45)
    at org.scalatest.tools.Runner$.doRunRunRunDaDoRunRun(Runner.scala:1514)
    at org.scalatest.tools.Runner$$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:584)
    at org.scalatest.tools.Runner$$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:583)
    at org.scalatest.tools.Runner$.withClassLoaderAndDispatchReporter(Runner.scala:1558)
    at org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:582)
    at org.scalatest.tools.Runner$.run(Runner.scala:485)
    at org.scalatest.tools.Runner.run(Runner.scala)
    at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTest15Scala28Runner.main(ScalaTest15Scala28Runner.java:34)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)


Process finished with exit code 0

The commented line below breaks my testing

import org.scalatest.WordSpec

class LSESuite extends WordSpec {

  "An LSE market" should {
    "round values" in  {
      val lse = new LSE {
      }
      assert(lse.getMarketName === "LSE")
      //"min tick size" is (pending)
    }
  }
}

I receive the following error "An it clause may not appear inside another it clause" but I'm not sure how to interpret. Edit stack trace:

org.scalatest.TestRegistrationClosedException: An it clause may not appear inside another it clause.
    at org.scalatest.SuperEngine.registerTest(Engine.scala:406)
    at org.scalatest.WordSpec$class.org$scalatest$WordSpec$registerTestToRun(WordSpec.scala:1643)
    at org.scalatest.WordSpec$WordSpecStringWrapper.is(WordSpec.scala:1823)


    at org.scalatest.WordSpec$anonfun$runTests$1.apply(WordSpec.scala:2232)
    at org.scalatest.WordSpec$anonfun$runTests$1.apply(WordSpec.scala:2232)
    at org.scalatest.SuperEngine$anonfun$org$scalatest$SuperEngine$runTestsInBranch$1.apply(Engine.scala:226)
    at org.scalatest.SuperEngine$anonfun$org$scalatest$SuperEngine$runTestsInBranch$1.apply(Engine.scala:215)
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
    at scala.collection.immutable.List.foreach(List.scala:45)
    at org.scalatest.SuperEngine.org$scalatest$SuperEngine$runTestsInBranch(Engine.scala:215)
    at org.scalatest.SuperEngine$anonfun$org$scalatest$SuperEngine$runTestsInBranch$1.apply(Engine.scala:231)
    at org.scalatest.SuperEngine$anonfun$org$scalatest$SuperEngine$runTestsInBranch$1.apply(Engine.scala:215)
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
    at scala.collection.immutable.List.foreach(List.scala:45)
    at org.scalatest.SuperEngine.org$scalatest$SuperEngine$runTestsInBranch(Engine.scala:215)
    at org.scalatest.SuperEngine.runTestsImpl(Engine.scala:282)
    at org.scalatest.WordSpec$class.runTests(WordSpec.scala:2232)
    at org.scalatest.Suite$class.run(Suite.scala:2286)
    at org.scalatest.WordSpec$anonfun$run$1.apply(WordSpec.scala:2279)
    at org.scalatest.WordSpec$anonfun$run$1.apply(WordSpec.scala:2279)
    at org.scalatest.SuperEngine.runImpl(Engine.scala:318)
    at org.scalatest.WordSpec$class.run(WordSpec.scala:2279)
    at org.scalatest.tools.SuiteRunner.run(SuiteRunner.scala:59)
    at org.scalatest.tools.Runner$anonfun$doRunRunRunDaDoRunRun$3.apply(Runner.scala:1517)
    at org.scalatest.tools.Runner$anonfun$doRunRunRunDaDoRunRun$3.apply(Runner.scala:1514)
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
    at scala.collection.immutable.List.foreach(List.scala:45)
    at org.scalatest.tools.Runner$.doRunRunRunDaDoRunRun(Runner.scala:1514)
    at org.scalatest.tools.Runner$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:584)
    at org.scalatest.tools.Runner$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:583)
    at org.scalatest.tools.Runner$.withClassLoaderAndDispatchReporter(Runner.scala:1558)
    at org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:582)
    at org.scalatest.tools.Runner$.run(Runner.scala:485)
    at org.scalatest.tools.Runner.run(Runner.scala)
    at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTest15Scala28Runner.main(ScalaTest15Scala28Runner.java:34)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)


Process finished with exit code 0

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

昵称有卵用 2024-12-11 23:22:52

您的“待处理”似乎位于一个奇怪的位置。因此,您可能会看到与我在这里看到的相同的问题:http://groups .google.com/group/scalatest-users/browse_thread/thread/177bbc520edc8fbd

Your 'pending' seems to be in an odd location. So you might see the same problem as I saw here: http://groups.google.com/group/scalatest-users/browse_thread/thread/177bbc520edc8fbd

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文