diff --git a/junit-interface/src/main/java/munit/internal/junitinterface/EventDispatcher.java b/junit-interface/src/main/java/munit/internal/junitinterface/EventDispatcher.java index d49a4eaa..70e7014d 100644 --- a/junit-interface/src/main/java/munit/internal/junitinterface/EventDispatcher.java +++ b/junit-interface/src/main/java/munit/internal/junitinterface/EventDispatcher.java @@ -75,9 +75,11 @@ public void testAssumptionFailure(final Failure failure) { failure.getDescription(), new ErrorEvent(failure, Status.Skipped) { void logTo(RichLogger logger) { - if (settings.verbose) { - logger.info(Ansi.c("==> i " + failure.getDescription().getMethodName(), WARNMSG)); - } + logger.warn( + settings.buildTestResult(Status.Skipped) + + ansiName + + Ansi.c(" skipped", SKIPPED) + + durationSuffix()); } }); } @@ -134,7 +136,7 @@ void logTo(RichLogger logger) { logger.warn( settings.buildTestResult(Status.Ignored) + ansiName - + " ignored" + + Ansi.c(" ignored", SKIPPED) + durationSuffix()); } }); @@ -163,7 +165,7 @@ private void recordStartTime(Description description) { private Long elapsedTime(Description description) { Long startTime = startTimes.get(description.getMethodName()); if (startTime == null) { - return 0l; + return 0L; } else { return System.currentTimeMillis() - startTime; } diff --git a/munit/js-native/src/main/scala/munit/internal/junitinterface/JUnitReporter.scala b/munit/js-native/src/main/scala/munit/internal/junitinterface/JUnitReporter.scala index a65fdefc..03d03f64 100644 --- a/munit/js-native/src/main/scala/munit/internal/junitinterface/JUnitReporter.scala +++ b/munit/js-native/src/main/scala/munit/internal/junitinterface/JUnitReporter.scala @@ -30,9 +30,7 @@ final class JUnitReporter( } def reportTestIgnored(method: String): Unit = { - if (settings.verbose) { - log(Info, AnsiColors.c(s"==> i $method ignored", AnsiColors.YELLOW)) - } + log(Info, AnsiColors.c(s"==> i $method ignored", AnsiColors.YELLOW)) emitEvent(method, Status.Ignored) } def reportAssumptionViolation( @@ -40,9 +38,7 @@ final class JUnitReporter( timeInSeconds: Double, e: Throwable ): Unit = { - if (settings.verbose) { - log(Info, AnsiColors.c(s"==> s $method skipped", AnsiColors.YELLOW)) - } + log(Info, AnsiColors.c(s"==> s $method skipped", AnsiColors.YELLOW)) emitEvent(method, Status.Skipped, new OptionalThrowable(e)) } def reportTestPassed(method: String, elapsedMillis: Double): Unit = { diff --git a/tests/shared/src/main/scala/munit/BaseSuite.scala b/tests/shared/src/main/scala/munit/BaseSuite.scala index ea2289a5..dddc0336 100644 --- a/tests/shared/src/main/scala/munit/BaseSuite.scala +++ b/tests/shared/src/main/scala/munit/BaseSuite.scala @@ -20,6 +20,8 @@ class BaseSuite extends FunSuite { test.tag(Ignore) } else if (test.tags(OnlyJVM) && !PlatformCompat.isJVM) { test.tag(Ignore) + } else if (test.tags(NoJVM) && PlatformCompat.isJVM) { + test.tag(Ignore) } else if (test.tags(NoNative) && PlatformCompat.isNative) { test.tag(Ignore) } else { diff --git a/tests/shared/src/main/scala/munit/SkippedFrameworkSuite.scala b/tests/shared/src/main/scala/munit/SkippedFrameworkSuite.scala index fb632b09..53e60ea2 100644 --- a/tests/shared/src/main/scala/munit/SkippedFrameworkSuite.scala +++ b/tests/shared/src/main/scala/munit/SkippedFrameworkSuite.scala @@ -23,5 +23,68 @@ object SkippedFrameworkSuite |==> ignored munit.SkippedFrameworkSuite.ignore |==> success munit.SkippedFrameworkSuite.assume(true) |==> skipped munit.SkippedFrameworkSuite.assume(false) - assume it fails - |""".stripMargin + |""".stripMargin, + format = SbtFormat + ) + +object SkippedFrameworkStdoutJsNativeSuite + extends FrameworkTest( + classOf[SkippedFrameworkSuite], + """|munit.SkippedFrameworkSuite: + | + pass + |==> i ignore ignored + | + assume(true) + |==> s assume(false) skipped + |""".stripMargin, + format = StdoutFormat, + tags = Set(NoJVM) + ) + +object SkippedFrameworkStdoutJsNativeVerboseSuite + extends FrameworkTest( + classOf[SkippedFrameworkSuite], + """|munit.SkippedFrameworkSuite: + |pass started + | + pass + |==> i ignore ignored + |assume(true) started + | + assume(true) + |assume(false) started + |==> s assume(false) skipped + |""".stripMargin, + format = StdoutFormat, + tags = Set(NoJVM), + arguments = Array("-v") + ) + +object SkippedFrameworkStdoutJVMSuite + extends FrameworkTest( + classOf[SkippedFrameworkSuite], + """|munit.SkippedFrameworkSuite: + | + pass + |==> i munit.SkippedFrameworkSuite.ignore ignored + | + assume(true) + |==> s munit.SkippedFrameworkSuite.assume(false) skipped + |""".stripMargin, + format = StdoutFormat, + tags = Set(OnlyJVM) + ) + +object SkippedFrameworkStdoutJVMVerboseSuite + extends FrameworkTest( + classOf[SkippedFrameworkSuite], + """|munit.SkippedFrameworkSuite started + |munit.SkippedFrameworkSuite: + |munit.SkippedFrameworkSuite.pass started + | + pass + |==> i munit.SkippedFrameworkSuite.ignore ignored + |munit.SkippedFrameworkSuite.assume(true) started + | + assume(true) + |munit.SkippedFrameworkSuite.assume(false) started + |==> s munit.SkippedFrameworkSuite.assume(false) skipped + |Test run munit.SkippedFrameworkSuite finished: 0 failed, 1 ignored, 3 total, + |""".stripMargin, + format = StdoutFormat, + tags = Set(OnlyJVM), + arguments = Array("-v") ) diff --git a/tests/shared/src/main/scala/munit/Tags.scala b/tests/shared/src/main/scala/munit/Tags.scala index b81797be..3e878299 100644 --- a/tests/shared/src/main/scala/munit/Tags.scala +++ b/tests/shared/src/main/scala/munit/Tags.scala @@ -1,6 +1,7 @@ package munit object OnlyJVM extends Tag("OnlyJVM") {} +object NoJVM extends Tag("NoJVM") {} object NoDotty extends Tag("NoDotty") {} object Only213 extends Tag("Only213") {} object NoNative extends Tag("NoNative") {} diff --git a/tests/shared/src/test/scala/munit/FrameworkSuite.scala b/tests/shared/src/test/scala/munit/FrameworkSuite.scala index e0f1c44f..26009fe6 100644 --- a/tests/shared/src/test/scala/munit/FrameworkSuite.scala +++ b/tests/shared/src/test/scala/munit/FrameworkSuite.scala @@ -33,7 +33,11 @@ class FrameworkSuite extends BaseFrameworkSuite { Issue583FrameworkSuite, ScalaCheckExceptionFrameworkSuite, BoxedFrameworkSuite, - SkippedFrameworkSuite + SkippedFrameworkSuite, + SkippedFrameworkStdoutJsNativeSuite, + SkippedFrameworkStdoutJVMSuite, + SkippedFrameworkStdoutJsNativeVerboseSuite, + SkippedFrameworkStdoutJVMVerboseSuite ) tests.foreach { t => check(t) } }