Last active
April 17, 2018 22:23
-
-
Save frgomes/4639d6fe08206fcb3a20ae002ca70ec7 to your computer and use it in GitHub Desktop.
Scala - utest: pending and ignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.typesafe.scalalogging.StrictLogging | |
trait uTestActions extends StrictLogging { | |
def ignored(action: ⇒ Unit): Unit = ignored | |
def pending(action: ⇒ Unit): Unit = { | |
try { | |
action | |
} catch { | |
case t: Throwable => pending(t) | |
} | |
} | |
private def ignored: Unit = { | |
val t = new RuntimeException | |
val it = t.getStackTrace.iterator | |
val e = (1 to 5).map(_ => it.next).last | |
report("IGNORED", e) | |
} | |
private def pending(t: Throwable): Unit = { | |
val pos = t.getStackTrace.zipWithIndex.find(p => p._1.getMethodName == "pending").get._2 | |
val it = t.getStackTrace.iterator | |
val e = (1 to pos+4).map(_ => it.next).last | |
report("PENDING", e) | |
} | |
private def report(state: String, e: StackTraceElement): Unit = { | |
val _class = e.getClassName | |
val _method = e.getMethodName | |
val _file = e.getFileName | |
val _line = e.getLineNumber | |
logger.error(s"@@@@@@@@ ${state}:: ${_class}.${_method} at ${_file}:${_line}") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment