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

Commit 0adac22

Browse files
authored
Merge pull request #21 from studyplus/feature/fix_test
StudyRecordTestをRobolectricTestRunnerで実行するよう修正
2 parents 6062ae1 + e24f78f commit 0adac22

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

studyplus-android-sdk2/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ dependencies {
5050

5151
testImplementation 'junit:junit:4.12'
5252
testImplementation 'org.robolectric:robolectric:4.0.2'
53-
testImplementation 'org.json:json:20180813'
5453
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
5554
testImplementation "com.squareup.okhttp3:mockwebserver:$okhttp"
5655
}

studyplus-android-sdk2/src/test/java/jp/studyplus/android/sdk/StudyRecordUnitTest.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@ import jp.studyplus.android.sdk.record.StudyRecordAmountRange
55
import jp.studyplus.android.sdk.record.StudyRecordAmountTotal
66
import org.junit.Assert.assertEquals
77
import org.junit.Test
8+
import org.junit.runner.RunWith
9+
import org.robolectric.RobolectricTestRunner
810
import java.util.*
911

12+
@RunWith(RobolectricTestRunner::class)
1013
class StudyRecordUnitTest {
1114

1215
@Test
1316
fun toJsonTest_littleParams() {
1417
val studyRecord = StudyRecord(2 * 60)
1518

1619
assertEquals(
17-
"{\"duration\":120,\"recorded_at\":\"${StudyRecord.formatTime(studyRecord.recordedTime)}\"}",
20+
"{\"recorded_at\":\"${StudyRecord.formatTime(studyRecord.recordedTime)}\",\"duration\":120}",
1821
studyRecord.toJson()
1922
)
2023
}
@@ -29,7 +32,7 @@ class StudyRecordUnitTest {
2932
)
3033

3134
assertEquals(
32-
"{\"duration\":120,\"recorded_at\":\"2019-06-01 01:02:03\",\"amount\":30,\"comment\":\"perfect!\"}",
35+
"{\"recorded_at\":\"2019-06-01 01:02:03\",\"duration\":120,\"comment\":\"perfect!\",\"amount\":30}",
3336
studyRecord.toJson()
3437
)
3538
}
@@ -44,7 +47,7 @@ class StudyRecordUnitTest {
4447
)
4548

4649
assertEquals(
47-
"{\"duration\":120,\"start_position\":5,\"recorded_at\":\"2019-06-01 01:02:03\",\"comment\":\"perfect!\",\"end_position\":12}",
50+
"{\"recorded_at\":\"2019-06-01 01:02:03\",\"duration\":120,\"comment\":\"perfect!\",\"start_position\":5,\"end_position\":12}",
4851
studyRecord.toJson()
4952
)
5053
}

0 commit comments

Comments
 (0)