Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Commit

Permalink
Generate proper JSON to display screenshots with titles. (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-zinnatullin authored Jun 29, 2017
1 parent 23c5851 commit 388bf9f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ gradle/local.properties
node_modules/
npm-debug.log*
test/
composer/src/main/resources/html-report/
22 changes: 18 additions & 4 deletions composer/src/main/kotlin/com/gojuno/composer/html/HtmlFullTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ data class HtmlFullTest(

@SerializedName("status")
val status: Status,

@SerializedName("stacktrace")
val stacktrace: String?,

Expand All @@ -43,8 +43,8 @@ data class HtmlFullTest(
@SerializedName("file_paths")
val filePaths: List<String>,

@SerializedName("screenshots_paths")
val screenshotsPaths: List<String>
@SerializedName("screenshots")
val screenshots: List<Screenshot>
) {
enum class Status {

Expand All @@ -57,6 +57,15 @@ data class HtmlFullTest(
@SerializedName("ignored")
Ignored
}

data class Screenshot(

@SerializedName("path")
val path: String,

@SerializedName("title")
val title: String
)
}

fun AdbDeviceTest.toHtmlFullTest(suiteId: String, htmlReportDir: File) = HtmlFullTest(
Expand All @@ -78,5 +87,10 @@ fun AdbDeviceTest.toHtmlFullTest(suiteId: String, htmlReportDir: File) = HtmlFul
deviceId = adbDevice.id,
properties = emptyMap(), // TODO: add properties support.
filePaths = files.map { it.relativePathTo(htmlReportDir) },
screenshotsPaths = screenshots.map { it.relativePathTo(htmlReportDir) }
screenshots = screenshots.map {
HtmlFullTest.Screenshot(
path = it.relativePathTo(htmlReportDir),
title = it.nameWithoutExtension
)
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class HtmlFullTestSpec : Spek({
stacktrace = null,
logcatPath = adbDeviceTest.logcat.name,
filePaths = adbDeviceTest.files.map { it.name },
screenshotsPaths = adbDeviceTest.screenshots.map { it.name },
screenshots = adbDeviceTest.screenshots.map { HtmlFullTest.Screenshot(path = it.name, title = it.nameWithoutExtension) },
deviceId = adbDeviceTest.adbDevice.id,
properties = emptyMap()
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class HtmlReportSpec : Spek({
<title>Composer</title>
<link href="../../../app.min.css" rel="stylesheet">
<script>
window.test = {"suite_id":"0","package_name":"com.gojuno.example1","class_name":"TestClass","name":"test1","id":"com.gojuno.example1TestClasstest1","duration_millis":1234,"status":"passed","logcat_path":"../../../com.gojuno.example1.TestClass/test1.logcat","deviceId":"device1","properties":{},"file_paths":["../../../com.gojuno.example1.TestClass.test1/file1","../../../com.gojuno.example1.TestClass.test1/file2"],"screenshots_paths":["../../../com.gojuno.example1.TestClass.test1/screenshot1","../../../com.gojuno.example1.TestClass.test1/screenshot2"]}
window.test = {"suite_id":"0","package_name":"com.gojuno.example1","class_name":"TestClass","name":"test1","id":"com.gojuno.example1TestClasstest1","duration_millis":1234,"status":"passed","logcat_path":"../../../com.gojuno.example1.TestClass/test1.logcat","deviceId":"device1","properties":{},"file_paths":["../../../com.gojuno.example1.TestClass.test1/file1","../../../com.gojuno.example1.TestClass.test1/file2"],"screenshots":[{"path":"../../../com.gojuno.example1.TestClass.test1/screenshot1","title":"screenshot1"},{"path":"../../../com.gojuno.example1.TestClass.test1/screenshot2","title":"screenshot2"}]}
// window.mainData / window.suite / window.test={ json }
</script>
</head>
Expand All @@ -180,7 +180,7 @@ class HtmlReportSpec : Spek({
<title>Composer</title>
<link href="../../../app.min.css" rel="stylesheet">
<script>
window.test = {"suite_id":"0","package_name":"com.gojuno.example1","class_name":"TestClass","name":"test2","id":"com.gojuno.example1TestClasstest2","duration_millis":1234,"status":"failed","stacktrace":"abc","logcat_path":"../../../com.gojuno.example1.TestClass/test2.logcat","deviceId":"device1","properties":{},"file_paths":["../../../com.gojuno.example1.TestClass.test2/file1","../../../com.gojuno.example1.TestClass.test2/file2"],"screenshots_paths":["../../../com.gojuno.example1.TestClass.test2/screenshot1","../../../com.gojuno.example1.TestClass.test2/screenshot2"]}
window.test = {"suite_id":"0","package_name":"com.gojuno.example1","class_name":"TestClass","name":"test2","id":"com.gojuno.example1TestClasstest2","duration_millis":1234,"status":"failed","stacktrace":"abc","logcat_path":"../../../com.gojuno.example1.TestClass/test2.logcat","deviceId":"device1","properties":{},"file_paths":["../../../com.gojuno.example1.TestClass.test2/file1","../../../com.gojuno.example1.TestClass.test2/file2"],"screenshots":[{"path":"../../../com.gojuno.example1.TestClass.test2/screenshot1","title":"screenshot1"},{"path":"../../../com.gojuno.example1.TestClass.test2/screenshot2","title":"screenshot2"}]}
// window.mainData / window.suite / window.test={ json }
</script>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class HtmlShortTestSpec : Spek({
stacktrace = null,
logcatPath = "testLogcatPath",
filePaths = listOf("testFilePath1", "testFilePath2"),
screenshotsPaths = listOf("testScreenshotPath1", "testScreenshotPath2"),
screenshots = listOf(HtmlFullTest.Screenshot(path = "testScreenshotPath1", title = "testScreenshot1"), HtmlFullTest.Screenshot(path = "testScreenshotPath2", title = "testScreenshot2")),
deviceId = "test-device-id",
properties = mapOf("key1" to "value1", "key2" to "value2")
)
Expand Down

0 comments on commit 388bf9f

Please sign in to comment.