- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 org.scalatest.FunSpec with org.scalatest.Matchers
执行以下操作的测试,例如
val tol = 1e-10
val res = 1.000000000000001
val ref = 1.000000000000000
res should be (ref +- tol)
name
以反射(reflect)它适用于哪个名称。我需要类似的东西:
val name : String = ...
res should be (ref +- tol) for name
it
和
describe
在这一点上,因为他们已经在外面。
最佳答案
这实际上取决于您要做什么,您可能应该添加一个更完整的示例来说明您要实现的目标,但您可以使用 describe
在循环。例如:
class TempTest extends FunSpec with Matchers {
describe("Some example test") {
(1 to 10).foreach { i => // your loop here
describe(s"Scenario $i") {
it("should be equal to itself") {
i shouldBe i
}
}
}
}
}
withClue
为匹配器添加更多上下文,例如:
withClue("Some clarifying message") {
i shouldBe 5
}
关于Scalatest:应该是带有额外描述的匹配器吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39829145/
有时测试是有效的,但被测试的代码是错误的,并且有针对测试场景的缺陷记录。修复缺陷后,测试将通过。 在那之前,我可以将测试标记为“忽略”,并在注释中添加缺陷编号。然后测试将不会运行,它会被标记为被忽略,
我正在尝试使用 scalatest Asynchronous Test Suites ,但除了对设置超时的一些限制之外,我看不到测试套件实际添加了什么。 我想知道是否有人精通使用 scalatest
如何使用其 maven 插件将命令行参数传递给 ScalaTest?我正在寻找类似 TestNG 的东西 delegateCommandSystemProperties配置,但我能在 ScalaTes
jasmine 和 junit 等测试框架提供了在运行每个测试之前配置测试环境的方法。 scalatest 和 playspec 中有类似的东西吗? 最佳答案 在scalatest中你可以使用Befo
禁用 scalatest log4j 消息日志记录的方法是什么: log4j.properties如下: log4j.rootLogger=INFO,CA,FA #Console Appender l
我正在尝试为 Akka Actor 编写单元测试。 下面是单元测试代码 import org.scalatest._ import akka.testkit.{TestKit, ImplicitSen
这里是 scala 的新手,正在经历一个 scala tutorial . 我正在尝试使用教程中提到的 scalatest 但出现此错误: [error] (*:update) sbt.Resolve
为什么这不能用 ScalaTest 2.0.M5b 编译? import org.scalatest.matchers.MatchResult import org.scalatest.matcher
我正在尝试为返回包含数组的类的元组的函数编写单元测试。 一个简单的assert(out === expectedOut)或 out should be(expectedOut)由于 Array,不比较
假设我有一个书单: val books = List( Book(title="Foo", year=2014), Book(title="Bar", year=2014)) 如果集合
我正在使用 flatspec 特征来创建我的测试,并且我想创建一个基类,该基类将使用特定标签自动标记该类中的任何测试。 例如,从 IntegrationTest 类继承的类中的任何测试都将自动被适当标
为了测试我的代码是否抛出预期的异常,我使用以下语法: an [IllegalArgumentException] should be thrownBy(Algorithms.create(degr
我刚开始使用 WordSpec,但遇到了一个无法解决的问题。 我想在一个单元测试中断言两个独立的值。假设我有 val result1 和 val result2,我需要第一个取一个特定值,第二个取另一
我想知道哪个ExecutionContext我应该在 scalatest % 2.2.6 上使用(以及为什么)运行我的 future 并模拟 future 。 class Foo { def f
我正在使用一些带有 blocking 语句的代码: blocking { Thread.sleep(10*1000) } 有没有办法断言给出了这个blocking语句?或者换句话说:如果有人删
有没有办法显示更好的错误信息?例如下面的代码 it should "check that items satisfy predicate" in { List(1,2,3,4,5,6).foral
当我使用 sbt 运行以下简单测试时,我得到了我期望的输出: import org.scalatest.{FlatSpec, Matchers, Suites} class TestSimple ex
我正在使用一个套件(Scalatest 版本:3.2.2),里面有几个 TestSuites: class SuiteMixedSequentialParallel extends Stepw
我在我的 Scala Play 项目中使用了 ScalaTest。但我在这里有一个问题,什么时候使用正常 assert(xxx === yyy)以及何时使用 ScalaTest 匹配器,如 xxx s
我正在使用 ScalaTest 测试我在 Scala 中编写的解析器。解析器一次处理一个文件,它有一个如下所示的单例对象: class Parser{...} object Resolver {...
我是一名优秀的程序员,十分优秀!