mam tej metody wygody moich testów:jak zignorować metody narzędzia testowego, gdy skalatest wykryje awarie?
def assertFormat[T: SexpFormat](start: T, expect: Sexp): Unit = {
val sexp = start.toSexp
assert(sexp === expect, s"${sexp.compactPrint} was not ${expect.compactPrint}")
expect.convertTo[T] should be(start)
}
, która jest w zasadzie wygoda dla prowadzenia wzór twierdzenie, że robię dużo.
To nie jest możliwe, aby przerobić to jako Matcher
ze względu na niejawny zapotrzebowania na SexpFormat[T]
(choć byłbym zainteresowany w rozprawie sposobów na to, że nie wymagają mi zrobić, aby zapisać typ MyFormat
w foo should roundTrip[MyFormat](...)
)
Jeśli jakiekolwiek testy zakończą się niepowodzeniem w tej metodzie narzędzia, skalatest będzie oznaczać elementy wewnętrzne assertFormat
jako przyczynę niepowodzenia testu. Ale naprawdę chcę, aby skalatest wykrył, że wywołanie tej metody jest przyczyną testu. Jak mogę to zrobić?
wyjście tj prąd
[info] - should support custom missing value rules *** FAILED ***
[info] SexpNil did not equal SexpCons(SexpSymbol(:duck),SexpCons(SexpNil,SexpNil)) nil was not (:duck nil) (FormatSpec.scala:11)
[info] org.scalatest.exceptions.TestFailedException:
[info] at org.scalatest.Assertions$class.newAssertionFailedException(Assertions.scala:529)
[info] at org.scalatest.FlatSpec.newAssertionFailedException(FlatSpec.scala:1691)
[info] at org.scalatest.Assertions$AssertionsHelper.macroAssert(Assertions.scala:502)
[info] at org.ensime.sexp.formats.FormatSpec$class.assertFormat(FormatSpec.scala:11)
[info] at org.ensime.sexp.formats.test.FamilyFormatsSpec.assertFormat(FamilyFormatsSpec.scala:151)
[info] at org.ensime.sexp.formats.test.FamilyFormatsSpec.roundtrip(FamilyFormatsSpec.scala:156)
[info] at org.ensime.sexp.formats.test.FamilyFormatsSpec$$anonfun$12.apply(FamilyFormatsSpec.scala:222)
[info] at org.ensime.sexp.formats.test.FamilyFormatsSpec$$anonfun$12.apply(FamilyFormatsSpec.scala:221)
FormatSpec.scala:11
gdzie moja assertFormat
jest zdefiniowana. Prawdziwa porażka jest w FamilyFormatsSpec.scala:222
(który dzwoni inna metoda wygoda FamilyFormatsSpec.scala:156
)