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

Commit c9a15aa

Browse files
koral--yunikkk
authored andcommitted
Add device name to HTML reports. Fixes #122. (#127)
1 parent 6e039df commit c9a15aa

File tree

15 files changed

+50
-17
lines changed

15 files changed

+50
-17
lines changed

composer/src/main/kotlin/com/gojuno/composer/Main.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ fun main(rawArgs: Array<String>) {
107107
devices = adbDeviceTestRuns.fold(emptyList()) { devices, adbDeviceTestRun ->
108108
devices + Device(
109109
id = adbDeviceTestRun.adbDevice.id,
110+
model = adbDeviceTestRun.adbDevice.model,
110111
logcat = adbDeviceTestRun.logcat,
111112
instrumentationOutput = adbDeviceTestRun.instrumentationOutput
112113
)
@@ -121,7 +122,7 @@ fun main(rawArgs: Array<String>) {
121122
timestampMillis = adbDeviceTestRuns.map { it.timestampMillis }.min() ?: -1
122123
))
123124

124-
// In "shard=false" mode test run from each device represented as own suite of tests.
125+
// In "shard=false" mode test run from each device represented as own suite of tests.
125126
false -> adbDeviceTestRuns.map { it.toSuite(args.testPackage) }
126127
}
127128
}
@@ -188,6 +189,7 @@ data class Suite(
188189

189190
data class Device(
190191
val id: String,
192+
val model:String,
191193
val logcat: File,
192194
val instrumentationOutput: File
193195
)
@@ -196,6 +198,7 @@ fun AdbDeviceTestRun.toSuite(testPackage: String): Suite = Suite(
196198
testPackage = testPackage,
197199
devices = listOf(Device(
198200
id = adbDevice.id,
201+
model = adbDevice.model,
199202
logcat = logcat,
200203
instrumentationOutput = instrumentationOutput
201204
)),

composer/src/main/kotlin/com/gojuno/composer/html/HtmlDevice.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ data class HtmlDevice(
99
@SerializedName("id")
1010
val id: String,
1111

12+
@SerializedName("model")
13+
val model: String,
14+
1215
@SerializedName("logcat_path")
1316
val logcatPath: String,
1417

@@ -18,6 +21,7 @@ data class HtmlDevice(
1821

1922
fun Device.toHtmlDevice(htmlReportDir: File) = HtmlDevice(
2023
id = id,
24+
model = model,
2125
logcatPath = logcat.relativePathTo(htmlReportDir),
2226
instrumentationOutputPath = instrumentationOutput.relativePathTo(htmlReportDir)
2327
)

composer/src/main/kotlin/com/gojuno/composer/html/HtmlFullTest.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ data class HtmlFullTest(
3737
@SerializedName("deviceId")
3838
val deviceId: String,
3939

40+
@SerializedName("deviceModel")
41+
val deviceModel: String,
42+
4043
@SerializedName("properties")
4144
val properties: Map<String, Any>,
4245

@@ -86,6 +89,7 @@ fun AdbDeviceTest.toHtmlFullTest(suiteId: String, htmlReportDir: File) = HtmlFul
8689
},
8790
logcatPath = logcat.relativePathTo(htmlReportDir),
8891
deviceId = adbDevice.id,
92+
deviceModel = adbDevice.model,
8993
properties = emptyMap(), // TODO: add properties support.
9094
filePaths = files.map { it.relativePathTo(htmlReportDir) },
9195
screenshots = screenshots.map {

composer/src/main/kotlin/com/gojuno/composer/html/HtmlShortTest.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ data class HtmlShortTest(
2525
@SerializedName("deviceId")
2626
val deviceId: String,
2727

28+
@SerializedName("deviceModel")
29+
val deviceModel: String,
30+
2831
@SerializedName("properties")
2932
val properties: Map<String, Any>
3033
)
@@ -37,5 +40,6 @@ fun HtmlFullTest.toHtmlShortTest() = HtmlShortTest(
3740
durationMillis = durationMillis,
3841
status = status,
3942
deviceId = deviceId,
43+
deviceModel = deviceModel,
4044
properties = properties
4145
)

composer/src/test/kotlin/com/gojuno/composer/JUnitReportSpec.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ class JUnitReportSpec : Spek({
2424
writeJunit4Report(
2525
suite = Suite(
2626
testPackage = "com.gojuno.test",
27-
devices = listOf(Device(id = adbDevice.id, logcat = testFile(), instrumentationOutput = testFile())),
27+
devices = listOf(Device(
28+
id = adbDevice.id,
29+
logcat = testFile(),
30+
instrumentationOutput = testFile(),
31+
model = adbDevice.model
32+
)),
2833
tests = listOf(
2934
AdbDeviceTest(
3035
adbDevice = adbDevice,

composer/src/test/kotlin/com/gojuno/composer/html/HtmlDeviceSpec.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ class HtmlDeviceSpec : Spek({
1111

1212
context("Device.toHtmlDevice") {
1313

14-
val device = Device(id = "testDevice1", logcat = testFile(), instrumentationOutput = testFile())
14+
val device = Device(id = "testDevice1", logcat = testFile(), instrumentationOutput = testFile(), model = "testModel1")
1515

1616
val htmlDevice = device.toHtmlDevice(testFile().parentFile)
1717

1818
it("converts Device to HtmlDevice") {
1919
assertThat(htmlDevice).isEqualTo(HtmlDevice(
2020
id = device.id,
21+
model = device.model,
2122
logcatPath = device.logcat.name,
2223
instrumentationOutputPath = device.instrumentationOutput.name
2324
))

composer/src/test/kotlin/com/gojuno/composer/html/HtmlFullSuiteSpec.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class HtmlFullSuiteSpec : Spek({
1717
val suite = Suite(
1818
testPackage = "p",
1919
devices = listOf(
20-
Device(id = "device1", logcat = testFile(), instrumentationOutput = testFile()),
21-
Device(id = "device2", logcat = testFile(), instrumentationOutput = testFile())
20+
Device(id = "device1", logcat = testFile(), instrumentationOutput = testFile(), model = "model1"),
21+
Device(id = "device2", logcat = testFile(), instrumentationOutput = testFile(), model = "model2")
2222
),
2323
tests = listOf(
2424
AdbDeviceTest(

composer/src/test/kotlin/com/gojuno/composer/html/HtmlFullTestSpec.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class HtmlFullTestSpec : Spek({
1414
context("AdbDeviceTest.toHtmlTest") {
1515

1616
val adbDeviceTest = AdbDeviceTest(
17-
adbDevice = AdbDevice(id = "testDevice", online = true),
17+
adbDevice = AdbDevice(id = "testDevice", online = true, model = "testModel"),
1818
className = "com.gojuno.example.TestClass",
1919
testName = "test1",
2020
status = AdbDeviceTest.Status.Passed,
@@ -32,6 +32,7 @@ class HtmlFullTestSpec : Spek({
3232
packageName = "com.gojuno.example",
3333
className = "TestClass",
3434
name = adbDeviceTest.testName,
35+
deviceModel = "testModel",
3536
status = HtmlFullTest.Status.Passed,
3637
durationMillis = NANOSECONDS.toMillis(adbDeviceTest.durationNanos),
3738
stacktrace = null,

composer/src/test/kotlin/com/gojuno/composer/html/HtmlReportSpec.kt

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,21 @@ class HtmlReportSpec : Spek({
2525

2626
val adbDevice1 = AdbDevice(
2727
id = "device1",
28-
online = true
28+
online = true,
29+
model = "model1"
2930
)
3031

3132
val suites by memoized {
3233
listOf(
3334
Suite(
3435
testPackage = "com.gojuno.example1",
35-
devices = listOf(Device(id = "device1", logcat = File(outputDir, "device1.logcat"), instrumentationOutput = File(outputDir, "device1.instrumentation"))),
36+
devices = listOf(
37+
Device(
38+
id = "device1",
39+
logcat = File(outputDir, "device1.logcat"),
40+
instrumentationOutput = File(outputDir, "device1.instrumentation"),
41+
model = "model1")
42+
),
3643
tests = listOf(
3744
AdbDeviceTest(
3845
adbDevice = adbDevice1,
@@ -102,7 +109,7 @@ class HtmlReportSpec : Spek({
102109
<title>Composer</title>
103110
<link href="app.min.css" rel="stylesheet">
104111
<script>
105-
window.mainData = {"suites":[{"id":"0","passed_count":2,"ignored_count":0,"failed_count":1,"duration_millis":2468,"devices":[{"id":"device1","logcat_path":"device1.logcat","instrumentation_output_path":"device1.instrumentation"}]}]}
112+
window.mainData = {"suites":[{"id":"0","passed_count":2,"ignored_count":0,"failed_count":1,"duration_millis":2468,"devices":[{"id":"device1","model":"model1","logcat_path":"device1.logcat","instrumentation_output_path":"device1.instrumentation"}]}]}
106113
// window.mainData / window.suite / window.test={ json }
107114
</script>
108115
</head>
@@ -128,14 +135,13 @@ class HtmlReportSpec : Spek({
128135
<title>Composer</title>
129136
<link href="../app.min.css" rel="stylesheet">
130137
<script>
131-
window.suite = {"id":"0","tests":[{"id":"com.gojuno.example1TestClasstest1","package_name":"com.gojuno.example1","class_name":"TestClass","name":"test1","duration_millis":1234,"status":"passed","deviceId":"device1","properties":{}},{"id":"com.gojuno.example1TestClasstest2","package_name":"com.gojuno.example1","class_name":"TestClass","name":"test2","duration_millis":1234,"status":"failed","deviceId":"device1","properties":{}}],"passed_count":2,"ignored_count":0,"failed_count":1,"duration_millis":2468,"devices":[{"id":"device1","logcat_path":"../device1.logcat","instrumentation_output_path":"../device1.instrumentation"}]}
138+
window.suite = {"id":"0","tests":[{"id":"com.gojuno.example1TestClasstest1","package_name":"com.gojuno.example1","class_name":"TestClass","name":"test1","duration_millis":1234,"status":"passed","deviceId":"device1","deviceModel":"model1","properties":{}},{"id":"com.gojuno.example1TestClasstest2","package_name":"com.gojuno.example1","class_name":"TestClass","name":"test2","duration_millis":1234,"status":"failed","deviceId":"device1","deviceModel":"model1","properties":{}}],"passed_count":2,"ignored_count":0,"failed_count":1,"duration_millis":2468,"devices":[{"id":"device1","model":"model1","logcat_path":"../device1.logcat","instrumentation_output_path":"../device1.instrumentation"}]}
132139
// window.mainData / window.suite / window.test={ json }
133140
</script>
134141
</head>
135142
<body>
136143
<div id="root"></div>
137144
<script type="text/javascript" src="../app.min.js"></script>
138-
139145
<div class="copy content">Generated with&nbsp;❤️&nbsp;&nbsp;by Juno at 15:17:57 UTC, Jun 7 2017</div>
140146
</body>
141147
</html>
@@ -154,7 +160,7 @@ class HtmlReportSpec : Spek({
154160
<title>Composer</title>
155161
<link href="../../../app.min.css" rel="stylesheet">
156162
<script>
157-
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"}]}
163+
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","deviceModel":"model1","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"}]}
158164
// window.mainData / window.suite / window.test={ json }
159165
</script>
160166
</head>
@@ -180,7 +186,7 @@ class HtmlReportSpec : Spek({
180186
<title>Composer</title>
181187
<link href="../../../app.min.css" rel="stylesheet">
182188
<script>
183-
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"}]}
189+
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","deviceModel":"model1","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"}]}
184190
// window.mainData / window.suite / window.test={ json }
185191
</script>
186192
</head>

composer/src/test/kotlin/com/gojuno/composer/html/HtmlShortSuiteSpec.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class HtmlShortSuiteSpec : Spek({
1818
Suite(
1919
testPackage = "p",
2020
devices = listOf(
21-
Device(id = "device1", logcat = testFile(), instrumentationOutput = testFile()),
22-
Device(id = "device2", logcat = testFile(), instrumentationOutput = testFile())
21+
Device(id = "device1", logcat = testFile(), instrumentationOutput = testFile(), model = "model1"),
22+
Device(id = "device2", logcat = testFile(), instrumentationOutput = testFile(), model = "model2")
2323
),
2424
tests = listOf(
2525
AdbDeviceTest(

0 commit comments

Comments
 (0)