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

Commit

Permalink
Merge pull request #21 from studyplus/feature/fix_test
Browse files Browse the repository at this point in the history
StudyRecordTestをRobolectricTestRunnerで実行するよう修正
  • Loading branch information
JASON13F authored May 30, 2019
2 parents 6062ae1 + e24f78f commit 0adac22
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 0 additions & 1 deletion studyplus-android-sdk2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ dependencies {

testImplementation 'junit:junit:4.12'
testImplementation 'org.robolectric:robolectric:4.0.2'
testImplementation 'org.json:json:20180813'
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
testImplementation "com.squareup.okhttp3:mockwebserver:$okhttp"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ import jp.studyplus.android.sdk.record.StudyRecordAmountRange
import jp.studyplus.android.sdk.record.StudyRecordAmountTotal
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import java.util.*

@RunWith(RobolectricTestRunner::class)
class StudyRecordUnitTest {

@Test
fun toJsonTest_littleParams() {
val studyRecord = StudyRecord(2 * 60)

assertEquals(
"{\"duration\":120,\"recorded_at\":\"${StudyRecord.formatTime(studyRecord.recordedTime)}\"}",
"{\"recorded_at\":\"${StudyRecord.formatTime(studyRecord.recordedTime)}\",\"duration\":120}",
studyRecord.toJson()
)
}
Expand All @@ -29,7 +32,7 @@ class StudyRecordUnitTest {
)

assertEquals(
"{\"duration\":120,\"recorded_at\":\"2019-06-01 01:02:03\",\"amount\":30,\"comment\":\"perfect!\"}",
"{\"recorded_at\":\"2019-06-01 01:02:03\",\"duration\":120,\"comment\":\"perfect!\",\"amount\":30}",
studyRecord.toJson()
)
}
Expand All @@ -44,7 +47,7 @@ class StudyRecordUnitTest {
)

assertEquals(
"{\"duration\":120,\"start_position\":5,\"recorded_at\":\"2019-06-01 01:02:03\",\"comment\":\"perfect!\",\"end_position\":12}",
"{\"recorded_at\":\"2019-06-01 01:02:03\",\"duration\":120,\"comment\":\"perfect!\",\"start_position\":5,\"end_position\":12}",
studyRecord.toJson()
)
}
Expand Down

0 comments on commit 0adac22

Please sign in to comment.