当我从 Intellij 中的包运行测试时(“包”->“运行”->“包”中的 ScalaTests)
@DoNotDiscover还运行了标记为 的测试。
报告了一个问题 ( youtrack.jetbrains.com ),但没有建议解决方法,也没有承诺修复。
有办法让这项工作发挥作用吗?
我想按顺序运行两个集成测试。如何在ZIO Test 中实现这一点?
这是套房:
suite("Undeploy a Package")(
testM("There is a Package") {
PackageDeployer.deploy(pckg) *> // first deploy
assertM(PackageUndeployer.undeploy(pckg), equalTo(StatusCode.NoContent))
},
testM(s"There is no Package") {
assertM(PackageUndeployer.undeploy(pckg), equalTo(StatusCode.NotFound))
})
Run Code Online (Sandbox Code Playgroud)
ZIO Test并行运行这两个测试。有没有办法强制它们按顺序运行?
我知道单元测试已损坏:
it should "be true" in {
assert(false)
}
Run Code Online (Sandbox Code Playgroud)
但是我现在不想修复它,而是将其标记为已跳过。在测试运行的输出中应该有一个高度可见且非常简洁的警告,这就是为什么注释代码是不够的。
我找到了cancel命令:
it should "be true" in {
cancel("skipped")
assert(false)
}
Run Code Online (Sandbox Code Playgroud)
虽然这在控制台中看起来不错sbt test:
[info] - should be true !!! CANCELED !!!
Run Code Online (Sandbox Code Playgroud)
它使用巨大的堆栈跟踪向 IntelliJ 中的控制台发送垃圾邮件:
Test Canceled: skipped
org.scalatest.exceptions.TestCanceledException: skipped
at org.scalatest.Assertions.newTestCanceledException(Assertions.scala:531)
at org.scalatest.Assertions.newTestCanceledException$(Assertions.scala:530)
at org.scalatest.FlatSpec.newTestCanceledException(FlatSpec.scala:1685)
at org.scalatest.Assertions.cancel(Assertions.scala:1141)
at org.scalatest.Assertions.cancel$(Assertions.scala:1137)
at org.scalatest.FlatSpec.cancel(FlatSpec.scala:1685)
at com.dreamlines.metronome.entities.MarshallingTest.$anonfun$new$3(MarshallingTest.scala:108)
at org.scalatest.OutcomeOf.outcomeOf(OutcomeOf.scala:85)
at org.scalatest.OutcomeOf.outcomeOf$(OutcomeOf.scala:83)
at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
at org.scalatest.Transformer.apply(Transformer.scala:22)
at org.scalatest.Transformer.apply(Transformer.scala:20)
at org.scalatest.FlatSpecLike$$anon$1.apply(FlatSpecLike.scala:1682)
at org.scalatest.TestSuite.withFixture(TestSuite.scala:196)
at org.scalatest.TestSuite.withFixture$(TestSuite.scala:195)
at org.scalatest.FlatSpec.withFixture(FlatSpec.scala:1685)
at org.scalatest.FlatSpecLike.invokeWithFixture$1(FlatSpecLike.scala:1680)
at org.scalatest.FlatSpecLike.$anonfun$runTest$1(FlatSpecLike.scala:1692) …Run Code Online (Sandbox Code Playgroud) 0.6.23从0.6.21以下位置迁移到ScalaJS 后:
(addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.23"))
我的sbt-build抛出以下异常:
...
[error] /Users/mpa/dev/Github/pme123/scala-adapters/project/Settings.scala:88:20: value %%% is not a member of String
[error] "org.scala-js" %%% "scalajs-dom" % "0.9.6"
[error] ^
[error] /Users/mpa/dev/Github/pme123/scala-adapters/project/Settings.scala:90:27: value %%% is not a member of String
[error] , "com.typesafe.play" %%% "play-json" % "2.6.1"
...
Run Code Online (Sandbox Code Playgroud)
这是来自的价值Settings.scala:
lazy val clientDependencies: Seq[Def.Setting[_]] = Def.settings(libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % "0.9.6"
, "org.scala-lang.modules" %% "scala-xml" % "1.0.6"
, ...
))
Run Code Online (Sandbox Code Playgroud)
以下是它的用法build.sbt: …
我在 Binding.scala 上使用带有 scalajs-leaflet 外观的 Leaflet,并且地图初始化/显示不正确。
为了重现该问题,我准备了一个lihaoyi/workbench类似于 scalajs-leaflet 中的页面。
首先,从https://github.com/mcku/scalajs-leaflet下载分叉的 scalajs-leaflet
sbt在scalajs-leaflet目录中运行。输入~ example/fastOptJSsbt。现在,一个 Web 服务器在端口 12345 上启动。
在浏览器中打开 http://localhost:12345/example/target/scala-2.12/classes/leaflet2binding-dev.html
问题是地图容器出现但内容(图块等)不正确。在窗口上进行小幅调整后,地图变得很好,这会触发_onResize传单的处理程序。
容器在Leaflet2Binding.scala文件中并且在初始化之前已经指定了它的大小:
val mapElement = <div id="mapid" style="width: 1000px; height: 600px;
position: relative; outline: currentcolor none medium;"
class="leaflet-container leaflet-touch leaflet-fade-anim
leaflet-grab leaflet-touch-drag leaflet-touch-zoom"
data:tabindex="0"></div>.asInstanceOf[HTMLElement]
Run Code Online (Sandbox Code Playgroud)
可以lmap.invalidateSize(true)在返回元素之前在以下行中
插入一行https://github.com/mcku/scalajs-leaflet/blob/83b770bc76de450567ababf6c7d2af0700dd58c9/example/src/main/scala/example/Leaflet2Binding.scala , but# L3在这种情况下没有帮助。即这里:
@dom def renderMap = {
val mapElement = ... (same element as above)
.. some …Run Code Online (Sandbox Code Playgroud) 我想运行evicted我的Mill项目。
通过SBT ,可以使用以下方法在 中完成sbt-console:
sbt>evicted
这将返回版本冲突警告列表:
[warn] Found version conflict(s) in library dependencies; some are suspected to be binary incompatible:
[warn] * com.typesafe:ssl-config-core_2.13:0.3.8 is selected over 0.4.0
[warn] +- com.typesafe.play:play-ws-standalone_2.13:2.0.6 (depends on 0.3.8)
[warn] +- com.typesafe.play:play_2.13:2.7.3 () (depends on 0.3.8)
[warn] +- com.typesafe.akka:akka-stream_2.13:2.5.23 () (depends on 0.4.0)
....
Run Code Online (Sandbox Code Playgroud)
米尔是如何做到这一点的?
我尝试了mill-console,没有命令(mill resolve _),谷歌也无法提供帮助。
我有以下功能,我想测试:
def people(id: Int): RIO[R, People]
Run Code Online (Sandbox Code Playgroud)
如果有一个,这个函数会返回 People id,resp。如果不是,则失败,例如:
IO.fail(ServiceException(s"No People with id $id"))
Run Code Online (Sandbox Code Playgroud)
快乐的案例有效,例如:
suite("Get a Person for an ID") (
testM("get Luke Skywalker") {
for {
peopleRef <- Ref.make(Vector(People()))
luke <- Swapi.>.people(1).provide(Test(peopleRef))
} yield assert(luke, equalTo(People()))
},
Run Code Online (Sandbox Code Playgroud)
但是我如何测试失败案例呢?我尝试了不同的东西,主要是类型不匹配。这是一个尝试:
testM("get not existing People") {
(for {
peopleRef <- Ref.make(Vector(People()))
failure = Swapi.>.people(2).provide(Test(peopleRef))
} yield assertM(failure, fail(Cause.die(ServiceException(s"No People with id 2")))
}
)
Run Code Online (Sandbox Code Playgroud) 我只找到了Joda Time的解决方案.
我的解决方案只有在最后一天不在第一周时才有效:
LocalDate.now() // or any other LocalDate
.withDayOfMonth(31)
.withMonth(12)
.get(weekFields.weekOfWeekBasedYear())
Run Code Online (Sandbox Code Playgroud)
那么Java Time中的正确方法是什么(比如Joda Time)?
I could not find anything on how to ignore a Suite or a Test with ZIO Test.
Whether in an example nor in the documentation (https://zio.dev/docs/usecases/usecases_testing)
There is an ignored in the test package object:
/**
* Creates an ignored test result.
*/
final val ignored: ZTest[Any, Nothing, Nothing] =
ZIO.succeed(TestSuccess.Ignored)
Run Code Online (Sandbox Code Playgroud)
But how can it be used in your code?
I tried different things, but with no success.