Skip to content

Commit

Permalink
Merge pull request #60 from NotMyFault/junit-5
Browse files Browse the repository at this point in the history
Move to JUnit 5
  • Loading branch information
jglick committed May 22, 2023
2 parents 33b1a5e + 9bc1e7d commit ac6e8ea
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 33 deletions.
12 changes: 9 additions & 3 deletions git-changelist-maven-extension/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,15 @@
<version>6.5.0.202303070854-r</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.9.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
package io.jenkins.tools.incrementals.git_changelist_maven_extension;

import org.apache.maven.artifact.versioning.ComparableVersion;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.Test;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;

public class MainTest {

Expand All @@ -43,7 +44,8 @@ public class MainTest {
"pr", "dev",
};

@Test public void alphaBeta() {
@Test
public void alphaBeta() {
String hash = "852b473a2b8c";
String sanitized = Main.sanitize(hash);
assertThat(hash + " has been sanitized to the expected format", sanitized, is("852b_473a_2b_8c"));
Expand Down
19 changes: 16 additions & 3 deletions maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<packaging>maven-plugin</packaging>
<properties>
<maven-plugin-tools.version>3.8.1</maven-plugin-tools.version>
<junit.version>5.9.3</junit.version>
</properties>

<prerequisites>
Expand Down Expand Up @@ -64,9 +65,21 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,27 @@
package io.jenkins.tools.incrementals.maven;

import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import java.util.Arrays;
import java.util.Collection;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import static org.junit.jupiter.api.Assertions.assertEquals;

@RunWith(Parameterized.class)
public class DetectIndentTest {

@Parameterized.Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] {
{ "abc", 0, ' ' }, { " abc", 2, ' ' }, { " abc", 4, ' ' }, { "\t\tabc", 2, '\t' }, { "\tabc", 1, '\t' }
});
}

private String input;

private int size;

private char type;

public DetectIndentTest(String input, int size, char type) {
this.input = input;
this.size = size;
this.type = type;
}

@Test
public void detectIndentSize() {
@ParameterizedTest
@MethodSource("data")
public void detectIndentSize(String input, int size, char type) {
DetectIndent detectIndent = new DetectIndent();
DetectIndent.Indent indent = detectIndent.detect(input);
Assert.assertEquals(size, indent.size);
Assert.assertEquals(type, indent.type);
assertEquals(size, indent.getSize());
assertEquals(type, indent.getType());
}
}

0 comments on commit ac6e8ea

Please sign in to comment.