Skip to content

Commit

Permalink
Make FailException extend AssertionError, fixes #215
Browse files Browse the repository at this point in the history
  • Loading branch information
Olafur Pall Geirsson committed Oct 18, 2020
1 parent eb4574c commit 051830e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public boolean shouldRun(Description d)
if(Pattern.matches(p, testName)) return true;

ignored.add(testName);
ed.testIgnored(d);
return false;
}
}
2 changes: 0 additions & 2 deletions munit/js/src/main/scala/java/io/File.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import java.nio.file.Path

import munit.internal.{JSIO, JSPath, NodeNIOPath}

import munit.internal._

// obtained implementation by experimentation on the JDK.
class File(path: String) {
def this(parent: String, child: String) =
Expand Down
2 changes: 1 addition & 1 deletion munit/shared/src/main/scala/munit/FailException.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class FailException(
val cause: Throwable,
val isStackTracesEnabled: Boolean,
val location: Location
) extends Exception(message, cause)
) extends AssertionError(message, cause)
with Serializable {
def this(message: String, location: Location) =
this(message, null, true, location)
Expand Down
6 changes: 3 additions & 3 deletions munit/shared/src/main/scala/munit/MUnitRunner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,12 @@ class MUnitRunner(val cls: Class[_ <: Suite], newInstance: () => Suite)
case e => e
}
val failure = new Failure(description, cause)
ex match {
case _: AssumptionViolatedException =>
notifier.fireTestAssumptionFailed(failure)
cause match {
case _: FailSuiteException =>
suiteAborted = true
notifier.fireTestFailure(failure)
case _: AssumptionViolatedException =>
notifier.fireTestAssumptionFailed(failure)
case _ =>
notifier.fireTestFailure(failure)
}
Expand Down
7 changes: 7 additions & 0 deletions tests/shared/src/test/scala/munit/FailExceptionSuite.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package munit

class FailExceptionSuite extends BaseSuite {
test("assertion-error") {
val error: AssertionError = new FailException("", Location.generate)
}
}

0 comments on commit 051830e

Please sign in to comment.