diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml
index e0d4d6ac49..a76d06ad5c 100644
--- a/.buildkite/pipeline.yml
+++ b/.buildkite/pipeline.yml
@@ -3,9 +3,31 @@
# https://github.com/buildkite-plugins/docker-buildkite-plugin/releases
# We propagate the environment to the container (sse https://github.com/buildkite-plugins/docker-buildkite-plugin#propagate-environment-optional-boolean)
-# Build debug version of the RiotX application, from the develop branch and the features branches
-
steps:
+ - label: "Compile and run Unit tests"
+ agents:
+ # We use a medium sized instance instead of the normal small ones because
+ # gradle build is long
+ queue: "medium"
+ commands:
+ - "./gradlew clean test --stacktrace"
+ plugins:
+ - docker#v3.1.0:
+ image: "runmymind/docker-android-sdk"
+ propagate-environment: true
+
+ - label: "Compile Android tests"
+ agents:
+ # We use a medium sized instance instead of the normal small ones because
+ # gradle build is long
+ queue: "medium"
+ commands:
+ - "./gradlew clean assembleAndroidTest --stacktrace"
+ plugins:
+ - docker#v3.1.0:
+ image: "runmymind/docker-android-sdk"
+ propagate-environment: true
+
- label: "Assemble GPlay Debug version"
agents:
# We use a medium sized instance instead of the normal small ones because
diff --git a/matrix-sdk-android-rx/build.gradle b/matrix-sdk-android-rx/build.gradle
index 31f928c241..1d8e81e44f 100644
--- a/matrix-sdk-android-rx/build.gradle
+++ b/matrix-sdk-android-rx/build.gradle
@@ -11,6 +11,8 @@ android {
versionCode 1
versionName "1.0"
+ // Multidex is useful for tests
+ multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
diff --git a/matrix-sdk-android-rx/src/androidTest/java/im/vector/matrix/rx/ExampleInstrumentedTest.java b/matrix-sdk-android-rx/src/androidTest/java/im/vector/matrix/rx/ExampleInstrumentedTest.java
deleted file mode 100644
index 986d40d1a9..0000000000
--- a/matrix-sdk-android-rx/src/androidTest/java/im/vector/matrix/rx/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2019 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package im.vector.matrix.rx;
-
-import android.content.Context;
-import androidx.test.InstrumentationRegistry;
-import androidx.test.runner.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.*;
-
-/**
- * Instrumented test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getTargetContext();
-
- assertEquals("im.vector.matrix.rx.test", appContext.getPackageName());
- }
-}
diff --git a/matrix-sdk-android-rx/src/test/java/im/vector/matrix/rx/ExampleUnitTest.java b/matrix-sdk-android-rx/src/test/java/im/vector/matrix/rx/ExampleUnitTest.java
deleted file mode 100644
index 6b7fcfe7e6..0000000000
--- a/matrix-sdk-android-rx/src/test/java/im/vector/matrix/rx/ExampleUnitTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2019 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package im.vector.matrix.rx;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * @see Testing documentation
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file
diff --git a/matrix-sdk-android/build.gradle b/matrix-sdk-android/build.gradle
index 3e6d3ea88b..ab5f122dbc 100644
--- a/matrix-sdk-android/build.gradle
+++ b/matrix-sdk-android/build.gradle
@@ -155,7 +155,8 @@ dependencies {
testImplementation 'junit:junit:4.12'
testImplementation 'org.robolectric:robolectric:4.3'
//testImplementation 'org.robolectric:shadows-support-v4:3.0'
- testImplementation 'io.mockk:mockk:1.9.3.kotlin12'
+ // Note: version sticks to 1.9.2 due to https://github.com/mockk/mockk/issues/281
+ testImplementation 'io.mockk:mockk:1.9.2.kotlin12'
testImplementation 'org.amshove.kluent:kluent-android:1.44'
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
@@ -165,7 +166,8 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'org.amshove.kluent:kluent-android:1.44'
- androidTestImplementation 'io.mockk:mockk-android:1.9.3.kotlin12'
+ // Note: version sticks to 1.9.2 due to https://github.com/mockk/mockk/issues/281
+ androidTestImplementation 'io.mockk:mockk-android:1.9.2.kotlin12'
androidTestImplementation "androidx.arch.core:core-testing:$lifecycle_version"
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
diff --git a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/InstrumentedTest.kt b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/InstrumentedTest.kt
index 3cd47d4998..99fe7d29b4 100644
--- a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/InstrumentedTest.kt
+++ b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/InstrumentedTest.kt
@@ -17,12 +17,12 @@
package im.vector.matrix.android
import android.content.Context
-import androidx.test.InstrumentationRegistry
+import androidx.test.core.app.ApplicationProvider
import java.io.File
interface InstrumentedTest {
fun context(): Context {
- return InstrumentationRegistry.getTargetContext()
+ return ApplicationProvider.getApplicationContext()
}
fun cacheDir(): File {
diff --git a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/auth/AuthenticatorTest.kt b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/auth/AuthenticatorTest.kt
index 7d33fae4d8..5c86f5ad22 100644
--- a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/auth/AuthenticatorTest.kt
+++ b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/auth/AuthenticatorTest.kt
@@ -17,8 +17,8 @@
package im.vector.matrix.android.auth
import androidx.test.annotation.UiThreadTest
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.GrantPermissionRule
-import androidx.test.runner.AndroidJUnit4
import im.vector.matrix.android.InstrumentedTest
import im.vector.matrix.android.OkReplayRuleChainNoActivity
import im.vector.matrix.android.api.auth.Authenticator
diff --git a/matrix-sdk-android/src/test/java/im/vector/matrix/android/api/pushrules/PushRuleActionsTest.kt b/matrix-sdk-android/src/test/java/im/vector/matrix/android/api/pushrules/PushRuleActionsTest.kt
index f98af53333..17543e9d25 100644
--- a/matrix-sdk-android/src/test/java/im/vector/matrix/android/api/pushrules/PushRuleActionsTest.kt
+++ b/matrix-sdk-android/src/test/java/im/vector/matrix/android/api/pushrules/PushRuleActionsTest.kt
@@ -18,7 +18,7 @@ package im.vector.matrix.android.api.pushrules
import im.vector.matrix.android.api.pushrules.rest.PushRule
import im.vector.matrix.android.internal.di.MoshiProvider
-import org.junit.Assert
+import org.junit.Assert.*
import org.junit.Test
class PushRuleActionsTest {
@@ -63,22 +63,17 @@ class PushRuleActionsTest {
val pushRule = MoshiProvider.providesMoshi().adapter(PushRule::class.java).fromJson(rawPushRule)
- Assert.assertNotNull("Should have parsed the rule", pushRule)
- Assert.assertNotNull("Failed to parse actions", Action.mapFrom(pushRule!!))
+ assertNotNull("Should have parsed the rule", pushRule)
- val actions = Action.mapFrom(pushRule)
- Assert.assertEquals(3, actions!!.size)
+ val actions = pushRule!!.getActions()
+ assertEquals(3, actions.size)
- Assert.assertEquals("First action should be notify", Action.Type.NOTIFY, actions[0].type)
+ assertTrue("First action should be notify", actions[0] is Action.Notify)
- Assert.assertEquals("Second action should be tweak", Action.Type.SET_TWEAK, actions[1].type)
- Assert.assertEquals("Second action tweak key should be sound", "sound", actions[1].tweak_action)
- Assert.assertEquals("Second action should have default as stringValue", "default", actions[1].stringValue)
- Assert.assertNull("Second action boolValue should be null", actions[1].boolValue)
+ assertTrue("Second action should be sound", actions[1] is Action.Sound)
+ assertEquals("Second action should have default sound", "default", (actions[1] as Action.Sound).sound)
- Assert.assertEquals("Third action should be tweak", Action.Type.SET_TWEAK, actions[2].type)
- Assert.assertEquals("Third action tweak key should be highlight", "highlight", actions[2].tweak_action)
- Assert.assertEquals("Third action tweak param should be false", false, actions[2].boolValue)
- Assert.assertNull("Third action stringValue should be null", actions[2].stringValue)
+ assertTrue("Third action should be highlight", actions[2] is Action.Highlight)
+ assertEquals("Third action tweak param should be false", false, (actions[2] as Action.Highlight).highlight)
}
}
diff --git a/matrix-sdk-android/src/test/java/im/vector/matrix/android/api/pushrules/PushrulesConditionTest.kt b/matrix-sdk-android/src/test/java/im/vector/matrix/android/api/pushrules/PushrulesConditionTest.kt
index 42e7e850b3..7651b32d20 100644
--- a/matrix-sdk-android/src/test/java/im/vector/matrix/android/api/pushrules/PushrulesConditionTest.kt
+++ b/matrix-sdk-android/src/test/java/im/vector/matrix/android/api/pushrules/PushrulesConditionTest.kt
@@ -199,6 +199,10 @@ class PushrulesConditionTest {
}
class MockRoom(override val roomId: String, val _numberOfJoinedMembers: Int) : Room {
+ override fun reportContent(eventId: String, score: Int, reason: String, callback: MatrixCallback): Cancelable {
+ TODO("not implemented") // To change body of created functions use File | Settings | File Templates.
+ }
+
override fun getReadMarkerLive(): LiveData> {
TODO("not implemented") // To change body of created functions use File | Settings | File Templates.
}
diff --git a/vector/src/androidTest/java/im/vector/riotx/ExampleInstrumentedTest.kt b/vector/src/androidTest/java/im/vector/riotx/ExampleInstrumentedTest.kt
deleted file mode 100644
index afed0c783a..0000000000
--- a/vector/src/androidTest/java/im/vector/riotx/ExampleInstrumentedTest.kt
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2019 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package im.vector.riotx
-
-import androidx.test.InstrumentationRegistry
-import androidx.test.runner.AndroidJUnit4
-
-import org.junit.Test
-import org.junit.runner.RunWith
-
-import org.junit.Assert.*
-
-/**
- * Instrumented test, which will execute on an Android device.
- *
- * See [testing documentation](http://d.android.com/tools/testing).
- */
-@RunWith(AndroidJUnit4::class)
-class ExampleInstrumentedTest {
- @Test
- fun useAppContext() {
- // Context of the app under test.
- val appContext = InstrumentationRegistry.getTargetContext()
- assertEquals("im.vector.riotx", appContext.packageName)
- }
-}
diff --git a/vector/src/test/java/im/vector/riotx/ExampleUnitTest.kt b/vector/src/test/java/im/vector/riotx/ExampleUnitTest.kt
deleted file mode 100644
index c51f642a1b..0000000000
--- a/vector/src/test/java/im/vector/riotx/ExampleUnitTest.kt
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2019 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package im.vector.riotx
-
-import org.junit.Test
-
-import org.junit.Assert.*
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * See [testing documentation](http://d.android.com/tools/testing).
- */
-class ExampleUnitTest {
- @Test
- fun addition_isCorrect() {
- assertEquals(4, 2 + 2)
- }
-}