Skip to content

Commit

Permalink
Merge pull request #766 from mzuehlke/reporting
Browse files Browse the repository at this point in the history
Align output for ignored and skipped tests between all 3 platforms
  • Loading branch information
tgodzik authored Apr 18, 2024
2 parents d45cf58 + cfca6bd commit dac6d06
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
});
}
Expand Down Expand Up @@ -134,7 +136,7 @@ void logTo(RichLogger logger) {
logger.warn(
settings.buildTestResult(Status.Ignored)
+ ansiName
+ " ignored"
+ Ansi.c(" ignored", SKIPPED)
+ durationSuffix());
}
});
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,15 @@ 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(
method: String,
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 = {
Expand Down
2 changes: 2 additions & 0 deletions tests/shared/src/main/scala/munit/BaseSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
65 changes: 64 additions & 1 deletion tests/shared/src/main/scala/munit/SkippedFrameworkSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 <elapsed time>
|==> i ignore ignored
| + assume(true) <elapsed time>
|==> s assume(false) skipped
|""".stripMargin,
format = StdoutFormat,
tags = Set(NoJVM)
)

object SkippedFrameworkStdoutJsNativeVerboseSuite
extends FrameworkTest(
classOf[SkippedFrameworkSuite],
"""|munit.SkippedFrameworkSuite:
|pass started
| + pass <elapsed time>
|==> i ignore ignored
|assume(true) started
| + assume(true) <elapsed time>
|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 <elapsed time>
|==> i munit.SkippedFrameworkSuite.ignore ignored <elapsed time>
| + assume(true) <elapsed time>
|==> s munit.SkippedFrameworkSuite.assume(false) skipped <elapsed time>
|""".stripMargin,
format = StdoutFormat,
tags = Set(OnlyJVM)
)

object SkippedFrameworkStdoutJVMVerboseSuite
extends FrameworkTest(
classOf[SkippedFrameworkSuite],
"""|munit.SkippedFrameworkSuite started
|munit.SkippedFrameworkSuite:
|munit.SkippedFrameworkSuite.pass started
| + pass <elapsed time>
|==> i munit.SkippedFrameworkSuite.ignore ignored <elapsed time>
|munit.SkippedFrameworkSuite.assume(true) started
| + assume(true) <elapsed time>
|munit.SkippedFrameworkSuite.assume(false) started
|==> s munit.SkippedFrameworkSuite.assume(false) skipped <elapsed time>
|Test run munit.SkippedFrameworkSuite finished: 0 failed, 1 ignored, 3 total, <elapsed time>
|""".stripMargin,
format = StdoutFormat,
tags = Set(OnlyJVM),
arguments = Array("-v")
)
1 change: 1 addition & 0 deletions tests/shared/src/main/scala/munit/Tags.scala
Original file line number Diff line number Diff line change
@@ -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") {}
6 changes: 5 additions & 1 deletion tests/shared/src/test/scala/munit/FrameworkSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ class FrameworkSuite extends BaseFrameworkSuite {
Issue497FrameworkSuite,
Issue583FrameworkSuite,
BoxedFrameworkSuite,
SkippedFrameworkSuite
SkippedFrameworkSuite,
SkippedFrameworkStdoutJsNativeSuite,
SkippedFrameworkStdoutJVMSuite,
SkippedFrameworkStdoutJsNativeVerboseSuite,
SkippedFrameworkStdoutJVMVerboseSuite
)
tests.foreach { t => check(t) }
}

0 comments on commit dac6d06

Please sign in to comment.