Skip to content

Commit b752ac6

Browse files
JUnit Jupiter best practices (#370)
Co-authored-by: Moderne <[email protected]>
1 parent 4cf2f78 commit b752ac6

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
* @author <a href="mailto:[email protected]">Allan Ramirez</a>
6969
*/
7070
@MojoTest
71-
public class InstallFileMojoTest {
71+
class InstallFileMojoTest {
7272
private static final String LOCAL_REPO = "target/local-repo";
7373

7474
private String groupId;
@@ -88,7 +88,7 @@ public class InstallFileMojoTest {
8888
ArtifactInstaller artifactInstaller;
8989

9090
@BeforeEach
91-
public void setUp() throws Exception {
91+
void setUp() throws Exception {
9292
FileUtils.deleteDirectory(new File(getBasedir() + "/" + LOCAL_REPO));
9393
}
9494

@@ -101,7 +101,7 @@ public void setUp() throws Exception {
101101
@MojoParameter(
102102
name = "file",
103103
value = "${project.basedir}/target/test-classes/unit/maven-install-test-1.0-SNAPSHOT.jar")
104-
public void testInstallFileTestEnvironment(InstallFileMojo mojo) {
104+
void installFileTestEnvironment(InstallFileMojo mojo) {
105105
assertNotNull(mojo);
106106
}
107107

@@ -114,7 +114,7 @@ public void testInstallFileTestEnvironment(InstallFileMojo mojo) {
114114
@MojoParameter(
115115
name = "file",
116116
value = "${project.basedir}/target/test-classes/unit/maven-install-test-1.0-SNAPSHOT.jar")
117-
public void testBasicInstallFile(InstallFileMojo mojo) throws Exception {
117+
void basicInstallFile(InstallFileMojo mojo) throws Exception {
118118
assertNotNull(mojo);
119119
assignValuesForParameter(mojo);
120120

@@ -141,7 +141,7 @@ public void testBasicInstallFile(InstallFileMojo mojo) throws Exception {
141141
@MojoParameter(name = "version", value = "1.0-SNAPSHOT")
142142
@MojoParameter(name = "packaging", value = "jar")
143143
@MojoParameter(name = "file", value = "${project.basedir}/target/test-classes/unit/file-does-not-exist.jar")
144-
public void testFileDoesNotExists(InstallFileMojo mojo) throws Exception {
144+
void fileDoesNotExists(InstallFileMojo mojo) throws Exception {
145145
assertNotNull(mojo);
146146
assignValuesForParameter(mojo);
147147

@@ -158,7 +158,7 @@ public void testFileDoesNotExists(InstallFileMojo mojo) throws Exception {
158158
@MojoParameter(
159159
name = "file",
160160
value = "${project.basedir}/target/test-classes/unit/maven-install-test-1.0-SNAPSHOT.jar")
161-
public void testInstallFileWithClassifier(InstallFileMojo mojo) throws Exception {
161+
void installFileWithClassifier(InstallFileMojo mojo) throws Exception {
162162
assertNotNull(mojo);
163163
assignValuesForParameter(mojo);
164164
assertNotNull(classifier);
@@ -188,7 +188,7 @@ public void testInstallFileWithClassifier(InstallFileMojo mojo) throws Exception
188188
name = "file",
189189
value = "${project.basedir}/target/test-classes/unit/maven-install-test-1.0-SNAPSHOT.jar")
190190
@MojoParameter(name = "generatePom", value = "true")
191-
public void testInstallFileWithGeneratePom(InstallFileMojo mojo) throws Exception {
191+
void installFileWithGeneratePom(InstallFileMojo mojo) throws Exception {
192192
assertNotNull(mojo);
193193
assignValuesForParameter(mojo);
194194
assertTrue((Boolean) getVariableValueFromObject(mojo, "generatePom"));
@@ -231,7 +231,7 @@ private Model readModel(Artifact pom) {
231231
name = "file",
232232
value = "${project.basedir}/target/test-classes/unit/maven-install-test-1.0-SNAPSHOT.jar")
233233
@MojoParameter(name = "pomFile", value = "${project.basedir}/src/test/resources/unit/pom.xml")
234-
public void testInstallFileWithPomFile(InstallFileMojo mojo) throws Exception {
234+
void installFileWithPomFile(InstallFileMojo mojo) throws Exception {
235235
assertNotNull(mojo);
236236
assignValuesForParameter(mojo);
237237
Path pomFile = (Path) getVariableValueFromObject(mojo, "pomFile");
@@ -257,7 +257,7 @@ public void testInstallFileWithPomFile(InstallFileMojo mojo) throws Exception {
257257
@MojoParameter(name = "version", value = "1.0-SNAPSHOT")
258258
@MojoParameter(name = "packaging", value = "pom")
259259
@MojoParameter(name = "file", value = "${project.basedir}/target/test-classes/unit/pom.xml")
260-
public void testInstallFileWithPomAsPackaging(InstallFileMojo mojo) throws Exception {
260+
void installFileWithPomAsPackaging(InstallFileMojo mojo) throws Exception {
261261
assertNotNull(mojo);
262262
assignValuesForParameter(mojo);
263263
assertTrue(Files.exists(file));
@@ -281,7 +281,7 @@ public void testInstallFileWithPomAsPackaging(InstallFileMojo mojo) throws Excep
281281
name = "file",
282282
value = "${project.basedir}/target/test-classes/unit/maven-install-test-1.0-SNAPSHOT.jar")
283283
@MojoParameter(name = "pomFile", value = "${project.basedir}/target/test-classes/unit/pom.xml")
284-
public void testInstallFile(InstallFileMojo mojo) throws Exception {
284+
void installFile(InstallFileMojo mojo) throws Exception {
285285
assertNotNull(mojo);
286286
assignValuesForParameter(mojo);
287287

src/test/java/org/apache/maven/plugins/install/InstallMojoPomPackagingTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
* @author <a href="mailto:[email protected]">Allan Ramirez</a>
6464
*/
6565
@MojoTest
66-
public class InstallMojoPomPackagingTest {
66+
class InstallMojoPomPackagingTest {
6767

6868
private static final String LOCAL_REPO = "target/local-repo/";
6969

@@ -80,14 +80,14 @@ public class InstallMojoPomPackagingTest {
8080
ProjectManager projectManager;
8181

8282
@BeforeEach
83-
public void setUp() throws Exception {
83+
void setUp() throws Exception {
8484
FileUtils.deleteDirectory(new File(getBasedir() + "/" + LOCAL_REPO));
8585
}
8686

8787
@Test
8888
@InjectMojo(goal = "install")
8989
@MojoParameter(name = "installAtEnd", value = "false")
90-
public void testInstallIfPackagingIsPom(InstallMojo mojo) throws Exception {
90+
void installIfPackagingIsPom(InstallMojo mojo) throws Exception {
9191
assertNotNull(mojo);
9292
Project project = (Project) getVariableValueFromObject(mojo, "project");
9393
String packaging = project.getPackaging().type().id();

src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
import static org.mockito.Mockito.when;
6767

6868
@MojoTest
69-
public class InstallMojoTest {
69+
class InstallMojoTest {
7070

7171
private static final String LOCAL_REPO = "target/local-repo/";
7272

@@ -83,20 +83,20 @@ public class InstallMojoTest {
8383
ProjectManager projectManager;
8484

8585
@BeforeEach
86-
public void setUp() throws Exception {
86+
void setUp() throws Exception {
8787
FileUtils.deleteDirectory(new File(getBasedir() + "/" + LOCAL_REPO));
8888
}
8989

9090
@Test
9191
@InjectMojo(goal = "install")
92-
public void testInstallTestEnvironment(InstallMojo mojo) {
92+
void installTestEnvironment(InstallMojo mojo) {
9393
assertNotNull(mojo);
9494
}
9595

9696
@Test
9797
@InjectMojo(goal = "install")
9898
@MojoParameter(name = "installAtEnd", value = "false")
99-
public void testBasicInstall(InstallMojo mojo) throws Exception {
99+
void basicInstall(InstallMojo mojo) throws Exception {
100100
assertNotNull(mojo);
101101
Project project = (Project) getVariableValueFromObject(mojo, "project");
102102
artifactManager.setPath(
@@ -117,7 +117,7 @@ public void testBasicInstall(InstallMojo mojo) throws Exception {
117117
@Test
118118
@InjectMojo(goal = "install")
119119
@MojoParameter(name = "installAtEnd", value = "false")
120-
public void testBasicInstallWithAttachedArtifacts(InstallMojo mojo) throws Exception {
120+
void basicInstallWithAttachedArtifacts(InstallMojo mojo) throws Exception {
121121
assertNotNull(mojo);
122122
Project project = (Project) getVariableValueFromObject(mojo, "project");
123123
projectManager.attachArtifact(
@@ -142,7 +142,7 @@ public void testBasicInstallWithAttachedArtifacts(InstallMojo mojo) throws Excep
142142

143143
@Test
144144
@InjectMojo(goal = "install")
145-
public void testInstallIfArtifactFileIsNull(InstallMojo mojo) throws Exception {
145+
void installIfArtifactFileIsNull(InstallMojo mojo) throws Exception {
146146
assertNotNull(mojo);
147147
Project project = (Project) getVariableValueFromObject(mojo, "project");
148148
assertFalse(artifactManager.getPath(project.getMainArtifact().get()).isPresent());
@@ -153,7 +153,7 @@ public void testInstallIfArtifactFileIsNull(InstallMojo mojo) throws Exception {
153153

154154
@Test
155155
@InjectMojo(goal = "install")
156-
public void testSkip(InstallMojo mojo) throws Exception {
156+
void skip(InstallMojo mojo) throws Exception {
157157
assertNotNull(mojo);
158158
setVariableValueToObject(mojo, "session", this.session);
159159
mojo.setSkip(true);

0 commit comments

Comments
 (0)