Skip to content
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

Add screenshot name to test report #294

Merged
Merged
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
26 changes: 16 additions & 10 deletions core/src/main/scala/com/karumi/shot/reports/ExecutionReporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ class ExecutionReporter {
val testName = screenshot.testName
val originalScreenshot = "./images/recorded/" + screenshot.name + ".png"
val width = (screenshot.screenshotDimension.width * 0.2).toInt
val screenshotName = screenshot.name
"<tr>" +
s"<th> <p>Test class: $testClass</p>" +
s"<p>Test name: $testName</p></th>" +
s"<p>Screenshot name: $screenshotName</p></th>" +
s"<th> <a href='$originalScreenshot'><img width='$width' src='$originalScreenshot'/></a></th>" +
"</tr>"
}
Expand Down Expand Up @@ -121,19 +123,21 @@ class ExecutionReporter {
): String = {
getSortedByResultScreenshots(comparision)
.map { case (screenshot, error) =>
val isFailedTest = error.isDefined
val testClass = screenshot.testClass
val testName = screenshot.testName
val result = if (isFailedTest) "❌" else "✅"
val reason = generateReasonMessage(error)
val color = if (isFailedTest) "red-text" else "green-text"
val id = screenshot.name.replace(".", "")
val isFailedTest = error.isDefined
val testClass = screenshot.testClass
val testName = screenshot.testName
val result = if (isFailedTest) "❌" else "✅"
val reason = generateReasonMessage(error)
val color = if (isFailedTest) "red-text" else "green-text"
val id = screenshot.name.replace(".", "")
val screenshotName = screenshot.name

if (showOnlyFailingTestsInReports && isFailedTest || !showOnlyFailingTestsInReports) {
"<tr>" +
s"<th><a href='#$id'>$result</a></th>" +
s"<th><a href='#$id'><p class='$color'>Test class: $testClass</p>" +
s"<p class='$color'>Test name: $testName</p></a></th>" +
s"<p class='$color'>Screenshot name: $screenshotName</p></th>" +
s"<th>$reason</th>" +
"</tr>"
} else {
Expand All @@ -159,14 +163,16 @@ class ExecutionReporter {
} else {
""
}
val color = if (isFailedTest) "red-text" else "green-text"
val width = (screenshot.screenshotDimension.width * 0.2).toInt
val id = screenshot.name.replace(".", "")
val color = if (isFailedTest) "red-text" else "green-text"
val width = (screenshot.screenshotDimension.width * 0.2).toInt
val id = screenshot.name.replace(".", "")
val screenshotName = screenshot.name

if (showOnlyFailingTestsInReports && isFailedTest || !showOnlyFailingTestsInReports) {
"<tr>" +
s"<th id='$id'> <p class='$color'>Test class: $testClass</p>" +
s"<p class='$color'>Test name: $testName</p></th>" +
s"<p class='$color'>Screenshot name: $screenshotName</p></th>" +
s"<th> <a href='$originalScreenshot'><img width='$width' src='$originalScreenshot'/></a></th>" +
s"<th> <a href='$newScreenshot'><img width='$width' src='$newScreenshot'/></a></th>" +
s"<th> <a href='$diff'><img width='$width' src='$diff'/></a></th>" +
Expand Down