77import org .mockito .junit .jupiter .MockitoExtension ;
88
99import static org .assertj .core .api .Assertions .assertThatThrownBy ;
10+ import static org .assertj .core .api .Assertions .assertThatCode ;
1011import static org .mockito .ArgumentMatchers .any ;
1112import static org .mockito .ArgumentMatchers .argThat ;
1213import static org .mockito .ArgumentMatchers .eq ;
1516import static org .mockito .Mockito .when ;
1617
1718@ ExtendWith (MockitoExtension .class )
18- public class CMakeBuilderTest {
19+ class CMakeBuilderTest {
1920
2021 private CMakeBuilder cmakeBuilder ;
2122
@@ -25,33 +26,32 @@ public class CMakeBuilderTest {
2526 private Github github ;
2627
2728 @ BeforeEach
28- public void setUp () {
29+ void setUp () {
2930 cmakeBuilder = new CMakeBuilder (fileSystem , github );
3031 }
3132
3233 @ Test
33- public void buildMustHaveAtLeastOneSourceFile () {
34+ void buildMustHaveAtLeastOneSourceFile () {
3435 // Given
3536 when (fileSystem .getProjectName ()).thenReturn ("MyProject" );
3637
37- // When
38- cmakeBuilder
39- .addSource ("main.cpp" )
40- .buildFiles ();
41-
42- // Then
43- // No exception
38+ // When/Then
39+ assertThatCode (() ->
40+ cmakeBuilder
41+ .addSource ("main.cpp" )
42+ .buildFiles ()
43+ ).doesNotThrowAnyException ();
4444 }
4545
4646 @ Test
47- public void buildMissingSourceFile () {
47+ void buildMissingSourceFile () {
4848 assertThatThrownBy (() -> cmakeBuilder
4949 .buildFiles ())
5050 .isInstanceOf (RuntimeException .class );
5151 }
5252
5353 @ Test
54- public void buildDefaultFiles () {
54+ void buildDefaultFiles () {
5555 // Given
5656 when (fileSystem .getProjectName ()).thenReturn ("MyProject" );
5757
@@ -71,14 +71,14 @@ public void buildDefaultFiles() {
7171 verify (fileSystem ).copyResourceTo ("src/main.cpp" );
7272
7373 verify (fileSystem , times (2 )).copyResourceTo (any (), any ());
74- verify (fileSystem , times (2 )).copyResourceTo (any ());
74+ verify (fileSystem , times (3 )).copyResourceTo (any ());
7575 verify (fileSystem , times (2 )).saveFileFromTemplate (any (), any ());
7676 verify (fileSystem , times (1 )).saveToFile (any (VcpkgObject .class ), eq ("vcpkg.json" ));
7777 verify (fileSystem , times (1 )).saveToFile (any (VcpkgConfigurationObject .class ), eq ("vcpkg-configuration.json" ));
7878 }
7979
8080 @ Test
81- public void buildProjectWithDependency () {
81+ void buildProjectWithDependency () {
8282 // Given
8383 when (fileSystem .getProjectName ()).thenReturn ("MyProject" );
8484 when (github .fetchLatestCommitSHA ("microsoft" , "vcpkg" ))
@@ -112,7 +112,7 @@ public void buildProjectWithDependency() {
112112 }
113113
114114 @ Test
115- public void buildTestProject () {
115+ void buildTestProject () {
116116 // Given
117117 when (fileSystem .getProjectName ()).thenReturn ("MyProject" );
118118
@@ -128,7 +128,7 @@ public void buildTestProject() {
128128 }
129129
130130 @ Test
131- public void buildWithLicenseFile () {
131+ void buildWithLicenseFile () {
132132 // Given
133133 when (fileSystem .getProjectName ()).thenReturn ("MyProject" );
134134
0 commit comments