1 /* <lambda>null2 * 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 platform.test.runner.parameterized 18 19 import com.google.common.truth.Truth.assertThat 20 import org.junit.ClassRule 21 import org.junit.Test 22 import org.junit.rules.TestRule 23 import org.junit.runner.RunWith 24 25 @RunWith(ParameterizedAndroidJunit4::class) 26 class ClassRuleCountTest(private val i: Int) { 27 companion object { 28 var howManyApplications = 0 29 30 @JvmStatic 31 @get:ClassRule 32 val countApplicationsRule = TestRule { base, _ -> 33 howManyApplications++ 34 base 35 } 36 37 @JvmStatic 38 @Parameters(name = "N = {0}") 39 fun data(): List<Array<Any>> { 40 return listOf(arrayOf(0), arrayOf(1)) 41 } 42 } 43 44 @Test 45 fun equalityWorks() { 46 assertThat(i).isEqualTo(i) 47 assertThat(howManyApplications).isEqualTo(1) 48 } 49 } 50