Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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}")
- }
- }
Add Comment
Please, Sign In to add comment