1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.atest.example; 18 19 import android.util.Log; 20 21 import androidx.test.filters.SmallTest; 22 23 import org.junit.After; 24 import org.junit.AfterClass; 25 import org.junit.Assert; 26 import org.junit.Before; 27 import org.junit.BeforeClass; 28 import org.junit.Test; 29 import org.junit.runner.RunWith; 30 import org.junit.runners.JUnit4; 31 32 @RunWith(JUnit4.class) 33 public class DeviceAndroidTest { 34 35 private static final String TAG = DeviceAndroidTest.class.getSimpleName(); 36 37 @BeforeClass beforeClass()38 public static void beforeClass() { 39 Log.d(TAG, "beforeClass()"); 40 } 41 42 @AfterClass afterClass()43 public static void afterClass() { 44 Log.d(TAG, "afterClass()"); 45 } 46 47 @Before before()48 public void before() { 49 Log.d(TAG, "before()"); 50 } 51 52 @After after()53 public void after() { 54 Log.d(TAG, "after()"); 55 } 56 57 @Test 58 @SmallTest testPassingTest1of2()59 public void testPassingTest1of2() { 60 Log.d(TAG, "testPassingTest1of2()"); 61 Assert.assertTrue(true); 62 } 63 64 @Test 65 @SmallTest testPassingTest2of2()66 public void testPassingTest2of2() { 67 Log.d(TAG, "testPassingTest2of2()"); 68 Assert.assertTrue(true); 69 } 70 71 @Test testFailingTest1of1()72 public void testFailingTest1of1() { 73 Log.d(TAG, "testFailingTest1of1()"); 74 Assert.assertTrue("Intentionally failed test.", false); 75 } 76 } 77