Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…covers records.

Relevant to #4384.

PiperOrigin-RevId: 657972168
  • Loading branch information
cpovirk authored and Error Prone Team committed Jul 31, 2024
1 parent ca7b569 commit f56c8b2
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

package com.google.errorprone.bugpatterns;

import static org.junit.Assume.assumeTrue;

import com.google.errorprone.CompilationTestHelper;
import com.google.errorprone.util.RuntimeVersion;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand All @@ -36,6 +39,26 @@ public void positiveCase() {
compilationHelper.addSourceFile("CannotMockFinalClassPositiveCases.java").doTest();
}

@Test
public void positiveCase_record() {
assumeTrue(RuntimeVersion.isAtLeast16());

compilationHelper
.addSourceLines(
"Test.java",
"import org.junit.runner.RunWith;",
"import org.junit.runners.JUnit4;",
"import org.mockito.Mock;",
"import org.mockito.Mockito;",
"@RunWith(JUnit4.class)",
"public class Test {",
" record Record() {}",
" // BUG: Diagnostic contains: ",
" @Mock Record record;",
"}")
.doTest();
}

@Test
public void negativeCase() {
compilationHelper.addSourceFile("CannotMockFinalClassNegativeCases.java").doTest();
Expand Down

0 comments on commit f56c8b2

Please sign in to comment.