Skip to content

Improved test failure display on the ScalaTest View #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion org.scala-ide.sdt.scalatest/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/home/cheeseng/git/scalatest-eclipse-plugin/org.scala-ide.sdt.scalatest/target/lib/scalatest-finders_2.9.0-0.9.2-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="target/lib/scalatest-finders_2.9.0-0.9.2-SNAPSHOT.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,4 @@ class ScalaTestLaunchDelegate extends AbstractJavaLaunchConfigurationDelegate {
}
}.filter(_ != "").mkString(" ")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,23 @@ class ScalaTestStackTrace(parent: Composite, fTestRunner: ScalaTestRunnerViewPar
}

def handleOpen(e: SelectionEvent) {
val selectedIdx = fTable.getSelectionIndex
if (selectedIdx >= 0) {
// Note that everything is shifted by one (since the proper error message, if any)
// AND it should be pointing to the same location as the 0th element on the list
val offset = node match {
case tm: TestModel => tm.errorMessage match {
case Some(_) => -1
case None => 0
}
case _ => 0
}

// Selection index might return -1 in some exceptional cases (e.g., widget disposed)
if (fTable.getSelectionIndex >= 0) {
// If we get the first (annotation) line selected, its index would be -1 without the max call
// But this way it will be correctly pointing to the same location where the test failed
val selectedIdx = math.max(fTable.getSelectionIndex + offset, 0)
fStackTraces match {
case Some(stackTraces) =>
case Some(stackTraces) =>
val foldedStackTraces = getFoldedStackTraces(stackTraces)
val stackTraceElement = foldedStackTraces(selectedIdx)
val model = JavaCore.create(ResourcesPlugin.getWorkspace.getRoot)
Expand Down Expand Up @@ -141,7 +154,16 @@ class ScalaTestStackTrace(parent: Composite, fTestRunner: ScalaTestRunnerViewPar
stackTraces match {
case Some(stackTraces) =>
val foldedStackTraces = getFoldedStackTraces(stackTraces)
val trace = foldedStackTraces.mkString("\n").trim
val testFailureMessage = node match {
case tm: TestModel => tm.errorMessage
case _ => None
}

val trace = (testFailureMessage match {
case Some(m) => m + "\n"
case None => ""
}) + foldedStackTraces.mkString("\n").trim

fTable.setRedraw(false)
fTable.removeAll()
new TextualTrace(trace, getFilterPatterns)
Expand Down