Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to JUnit 5 #60

Merged
merged 5 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() {
jglick marked this conversation as resolved.
Show resolved Hide resolved
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;
}
NotMyFault marked this conversation as resolved.
Show resolved Hide resolved

@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());
}
}