-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix interference between spies when spying on records (#3173)
Fixes #3160 Co-authored-by: Mikaël Francoeur <mikael.francoeur@ticketmaster.com>
- Loading branch information
Showing
3 changed files
with
33 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
26 changes: 26 additions & 0 deletions
26
subprojects/java21/src/test/java/org/mockito/java21/RecordTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 2023 Mockito contributors | ||
* This program is made available under the terms of the MIT License. | ||
*/ | ||
package org.mockito.java21; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.spy; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
|
||
public class RecordTest { | ||
|
||
@Test | ||
public void given_list_is_already_spied__when_spying_record__then_record_fields_are_correctly_populated() { | ||
var ignored = spy(List.of()); | ||
|
||
record MyRecord(String name) { | ||
} | ||
MyRecord spiedRecord = spy(new MyRecord("something")); | ||
|
||
assertThat(spiedRecord.name()).isEqualTo("something"); | ||
} | ||
} |