diff options
author | 2022-04-20 16:36:00 +0100 | |
---|---|---|
committer | 2022-05-11 19:30:46 +0000 | |
commit | cad672801b2ec3014409f2391021ff076bd28b9c (patch) | |
tree | beffa5613388c9a2cf83a43d4443b0801cff6e2c | |
parent | 3ef99b206119cd94b435222c1d0f7254992fe415 (diff) |
Update the .bp file and the skeleton of ArtServiceTests.
- Change the test to `android_test`, which is commonly used for mainline
module unit tests. (`java_test` doesn't work with Mockito, which is an
essential library for unit testing. It may also cause other problems
in the future.)
- Specify sdk_version and min_sdk_version.
- Migrate the test to using Mockito JUnit test runner.
- Migrate the test to using Truth.
Bug: 177273468
Test: atest ArtServiceTests
Change-Id: I7c25b3cf95b6fd5ee7d749bf08cfdd8c41ba89c9
Merged-In: I7c25b3cf95b6fd5ee7d749bf08cfdd8c41ba89c9
(cherry picked from commit a9aebb93d4c5899729c87ff981aa587ed2f00491)
-rw-r--r-- | libartservice/tests/Android.bp | 8 | ||||
-rw-r--r-- | libartservice/tests/AndroidManifest.xml | 30 | ||||
-rw-r--r-- | libartservice/tests/src/com/android/server/art/ArtManagerLocalTests.java | 21 |
3 files changed, 51 insertions, 8 deletions
diff --git a/libartservice/tests/Android.bp b/libartservice/tests/Android.bp index dc110a1a61..1b18cc5d45 100644 --- a/libartservice/tests/Android.bp +++ b/libartservice/tests/Android.bp @@ -27,7 +27,7 @@ package { default_applicable_licenses: ["art_license"], } -java_test { +android_test { name: "ArtServiceTests", // Include all test java files. @@ -36,9 +36,15 @@ java_test { ], static_libs: [ + "androidx.test.ext.junit", + "androidx.test.ext.truth", "androidx.test.runner", + "mockito-target-minus-junit4", "service-art.impl", ], + sdk_version: "system_server_current", + min_sdk_version: "31", + test_suites: ["general-tests"], } diff --git a/libartservice/tests/AndroidManifest.xml b/libartservice/tests/AndroidManifest.xml new file mode 100644 index 0000000000..921bde92c1 --- /dev/null +++ b/libartservice/tests/AndroidManifest.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> + +<!-- + ~ Copyright (C) 2022 The Android Open Source Project + ~ + ~ 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. + --> + +<manifest + xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.server.art.tests"> + + <application android:label="ArtServiceTests"> + <uses-library android:name="android.test.runner" /> + </application> + + <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" + android:targetPackage="com.android.server.art.tests" + android:label="Tests for ART Serices" /> +</manifest> diff --git a/libartservice/tests/src/com/android/server/art/ArtManagerLocalTests.java b/libartservice/tests/src/com/android/server/art/ArtManagerLocalTests.java index 515849b148..b0323c4b5d 100644 --- a/libartservice/tests/src/com/android/server/art/ArtManagerLocalTests.java +++ b/libartservice/tests/src/com/android/server/art/ArtManagerLocalTests.java @@ -16,22 +16,29 @@ package com.android.server.art; -import static org.junit.Assert.assertTrue; +import static com.google.common.truth.Truth.assertThat; -import androidx.test.runner.AndroidJUnit4; +import androidx.test.filters.SmallTest; import com.android.server.art.ArtManagerLocal; -import junit.framework.TestCase; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; -public class ArtManagerLocalTests extends TestCase { +@SmallTest +@RunWith(MockitoJUnitRunner.class) +public class ArtManagerLocalTests { private ArtManagerLocal mArtManagerLocal; - public void setup() { + @Before + public void setUp() { mArtManagerLocal = new ArtManagerLocal(); } + @Test public void testScaffolding() { - assertTrue(true); + assertThat(true).isTrue(); } -}
\ No newline at end of file +} |