Skip to content

Commit e7af496

Browse files
author
Gordon Wallace
committed
Added kotlin to the test sourceSets.
Added ExportSpec using JUnit4
1 parent 06034f4 commit e7af496

File tree

5 files changed

+54
-58
lines changed

5 files changed

+54
-58
lines changed

app/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ dependencies {
4444
testImplementation 'com.googlecode.junit-toolbox:junit-toolbox:2.4'
4545
testImplementation 'org.robolectric:robolectric:4.3.1'
4646
testImplementation 'androidx.test.ext:junit:1.1.1'
47+
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
4748
// Android Test Dependencies
4849
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
4950
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
@@ -54,8 +55,8 @@ android {
5455
compileSdkVersion 29
5556
buildToolsVersion "29.0.3"
5657

57-
sourceSets {
58-
main.java.srcDirs += 'src/main/kotlin'
58+
sourceSets.each {
59+
it.java.srcDirs += "src/$it.name/kotlin"
5960
}
6061

6162
defaultConfig {

app/build.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#Build Properties
2-
#Sun Mar 08 16:16:34 EDT 2020
2+
#Tue Mar 10 12:25:58 EDT 2020
33
version_minor=1
4-
version_build=26
4+
version_build=27
55
version_patch=1
6-
version_major=2
76
version_store=51
7+
version_major=2

app/jacoco.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) {
4242
def mainSrc = "$project.projectDir/src/main/java"
4343
def debugTree = fileTree(dir: classDir, excludes: fileFilter)
4444

45-
sourceDirectories = files([mainSrc])
46-
classDirectories = files([debugTree])
47-
executionData = fileTree(dir: project.buildDir, includes: [
45+
sourceDirectories.from = files([mainSrc])
46+
classDirectories.from = files([debugTree])
47+
executionData.from = fileTree(dir: project.buildDir, includes: [
4848
'jacoco/testDebugUnitTest.exec',
4949
'outputs/code-coverage/connected/*coverage.ec'
5050
])

app/src/test/java/com/vrem/wifianalyzer/export/ExportTest.java

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* WiFiAnalyzer
3+
* Copyright (C) 2019 VREM Software Development <[email protected]>
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>
17+
*/
18+
19+
package com.vrem.wifianalyzer.export
20+
21+
import com.vrem.wifianalyzer.wifi.band.WiFiWidth
22+
import com.vrem.wifianalyzer.wifi.model.WiFiDetail
23+
import com.vrem.wifianalyzer.wifi.model.WiFiSignal
24+
import org.junit.Assert.assertEquals
25+
import org.junit.Test
26+
import java.util.*
27+
28+
class ExportSpec {
29+
30+
private val timestamp = "timestamp"
31+
32+
private val wiFiDetails = listOf(WiFiDetail("SSID", "BSSID", "capabilities", WiFiSignal(2412, 2422, WiFiWidth.MHZ_40, -40, true)))
33+
34+
@Test
35+
fun `getData should evaluate to an export string`() {
36+
37+
val expected = String.format(Locale.ENGLISH,
38+
"Time Stamp|SSID|BSSID|Strength|Primary Channel|Primary Frequency|Center Channel|Center Frequency|Width (Range)|Distance|802.11mc|Security%n"
39+
+ timestamp + "|SSID|BSSID|-40dBm|1|2412MHz|3|2422MHz|40MHz (2402 - 2442)|~1.0m|true|capabilities%n")
40+
41+
val actual = getData(wiFiDetails, timestamp)
42+
43+
assertEquals(expected, actual)
44+
}
45+
}

0 commit comments

Comments
 (0)