Guest User

Untitled

a guest
Apr 25th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. import com.typesafe.scalalogging.StrictLogging
  2. trait uTestActions extends StrictLogging {
  3. def ignored(action: ⇒ Unit): Unit = ignored
  4. def pending(action: ⇒ Unit): Unit = {
  5. try {
  6. action
  7. } catch {
  8. case t: Throwable => pending(t)
  9. }
  10. }
  11.  
  12. private def ignored: Unit = {
  13. val t = new RuntimeException
  14. val it = t.getStackTrace.iterator
  15. val e = (1 to 5).map(_ => it.next).last
  16. report("IGNORED", e)
  17. }
  18.  
  19. private def pending(t: Throwable): Unit = {
  20. val pos = t.getStackTrace.zipWithIndex.find(p => p._1.getMethodName == "pending").get._2
  21. val it = t.getStackTrace.iterator
  22. val e = (1 to pos+4).map(_ => it.next).last
  23. report("PENDING", e)
  24. }
  25.  
  26. private def report(state: String, e: StackTraceElement): Unit = {
  27. val _class = e.getClassName
  28. val _method = e.getMethodName
  29. val _file = e.getFileName
  30. val _line = e.getLineNumber
  31. logger.error(s"@@@@@@@@ ${state}:: ${_class}.${_method} at ${_file}:${_line}")
  32. }
  33. }
Add Comment
Please, Sign In to add comment