从sbt中调用我的测试时排除ScalaTest测试
发布时间:2020-12-16 08:53:00 所属栏目:安全 来源:网络整理
导读:我想编写一个调用远程服务器的测试并验证响应,因为服务器可能会更改(它不在我的控制之下).要做到这一点,我想我 give it a tag(RemoteTest)然后 exclude it when calling the runner: sbt test-only * -- -l RemoteTest 但是,执行此操作时,我的所有测试都会
我想编写一个调用远程服务器的测试并验证响应,因为服务器可能会更改(它不在我的控制之下).要做到这一点,我想我
give it a tag(RemoteTest)然后
exclude it when calling the runner:
sbt> test-only * -- -l RemoteTest 但是,执行此操作时,我的所有测试都会运行,包括RemoteTest.如何从sbt内调用跑步者以排除它? 解决方法
如果您有以下内容: –
package com.test import org.scalatest.FlatSpec import org.scalatest.Tag object SlowTest extends Tag("com.mycompany.tags.SlowTest") object DbTest extends Tag("com.mycompany.tags.DbTest") class TestSuite extends FlatSpec { "The Scala language" must "add correctly" taggedAs(SlowTest) in { val sum = 1 + 1 assert(sum === 2) } it must "subtract correctly" taggedAs(SlowTest,DbTest) in { val diff = 4 - 1 assert(diff === 3) } } 要排除DbTest标记,您可以: – test-only * -- -l com.mycompany.tags.DbTest 请注意,您需要包含完整的标记名称.如果它仍然不适合你,你介意分享一些不起作用的源代码吗? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |