Skip to content

Commit

Permalink
[junit5] Migrate entire framework from junit4 to junit5 jupiter
Browse files Browse the repository at this point in the history
- Drop unnecessary powermock modules for junit 4
- Add mockito latest to cover powermock items out of the box (no extensions needed)
- Enable the parameterized tests and fix as now work
  • Loading branch information
hazendaz committed Dec 28, 2023
1 parent 775197f commit 1633776
Show file tree
Hide file tree
Showing 64 changed files with 728 additions and 761 deletions.
18 changes: 12 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -300,20 +300,26 @@

<!-- for testing -->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.10.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>${powermock.version}</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.10.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.8.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<artifactId>powermock-api-mockito2</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
Expand Down
7 changes: 3 additions & 4 deletions src/test/java/LiveDemoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@
import java.util.Collections;
import java.util.List;

import org.junit.Test;

import net.masterthought.cucumber.Configuration;
import net.masterthought.cucumber.ReportBuilder;
import net.masterthought.cucumber.presentation.PresentationMode;
import net.masterthought.cucumber.sorting.SortingMethod;
import org.junit.jupiter.api.Test;

/**
* @author Damian Szczepanik (damianszczepanik@github)
*/
public class LiveDemoTest {
class LiveDemoTest {

// test annotation only to make sure it is generated during "mvn test"
// what is needed to publish generated report via github.com
// http://damianszczepanik.github.io/cucumber-html-reports/overview-features.html
@Test
public void generateDemoReport() throws IOException {
void generateDemoReport() throws IOException {
File reportOutputDirectory = new File("target/demo");
List<String> jsonFiles = new ArrayList<>();
jsonFiles.add("src/test/resources/json/sample.json");
Expand Down
64 changes: 32 additions & 32 deletions src/test/java/net/masterthought/cucumber/ConfigurationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
import net.masterthought.cucumber.presentation.PresentationMode;
import net.masterthought.cucumber.reducers.ReducingMethod;
import net.masterthought.cucumber.sorting.SortingMethod;
import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* @author Damian Szczepanik (damianszczepanik@github)
*/
public class ConfigurationTest {
class ConfigurationTest {

private static final File outputDirectory = new File("abc");

private final String projectName = "123";

@Test
public void getReportDirectory_ReturnsOutputDirectory() {
void getReportDirectory_ReturnsOutputDirectory() {

// given
Configuration configuration = new Configuration(outputDirectory, projectName);
Expand All @@ -41,7 +41,7 @@ public void getReportDirectory_ReturnsOutputDirectory() {
}

@Test
public void getTrendsStatsFile_ReturnsTrendsFile() {
void getTrendsStatsFile_ReturnsTrendsFile() {

// given
File file = new File("ble");
Expand All @@ -55,7 +55,7 @@ public void getTrendsStatsFile_ReturnsTrendsFile() {
}

@Test
public void isTrendsStatsFile_ChecksIfTrendsFileWasSet() {
void isTrendsStatsFile_ChecksIfTrendsFileWasSet() {

// given
File file = new File("ble");
Expand All @@ -69,7 +69,7 @@ public void isTrendsStatsFile_ChecksIfTrendsFileWasSet() {
}

@Test
public void getTrendsLimit_ReturnsLimitForTrends() {
void getTrendsLimit_ReturnsLimitForTrends() {

// given
final int limit = 123;
Expand All @@ -83,7 +83,7 @@ public void getTrendsLimit_ReturnsLimitForTrends() {
}

@Test
public void isTrendsAvailable_OnNoTrendsPage_ReturnsFalse() {
void isTrendsAvailable_OnNoTrendsPage_ReturnsFalse() {

// given
final int limit = -1;
Expand All @@ -98,7 +98,7 @@ public void isTrendsAvailable_OnNoTrendsPage_ReturnsFalse() {
}

@Test
public void isTrendsAvailable_OnNoTrendsFile_ReturnsFalse() {
void isTrendsAvailable_OnNoTrendsFile_ReturnsFalse() {

// given
final int limit = 10;
Expand All @@ -112,7 +112,7 @@ public void isTrendsAvailable_OnNoTrendsFile_ReturnsFalse() {
}

@Test
public void getBuildNumber_ReturnsBuildNumber() {
void getBuildNumber_ReturnsBuildNumber() {

// given
Configuration configuration = new Configuration(outputDirectory, projectName);
Expand All @@ -127,7 +127,7 @@ public void getBuildNumber_ReturnsBuildNumber() {
}

@Test
public void getProjectName_ReturnsProjectName() {
void getProjectName_ReturnsProjectName() {

// given
Configuration configuration = new Configuration(outputDirectory, projectName);
Expand All @@ -140,7 +140,7 @@ public void getProjectName_ReturnsProjectName() {
}

@Test
public void getTagsToExcludeFromChart_ReturnsEmptyList() {
void getTagsToExcludeFromChart_ReturnsEmptyList() {

// given
Configuration configuration = new Configuration(outputDirectory, projectName);
Expand All @@ -153,7 +153,7 @@ public void getTagsToExcludeFromChart_ReturnsEmptyList() {
}

@Test
public void getDirectorySuffix_ReturnsDirectorySuffix() {
void getDirectorySuffix_ReturnsDirectorySuffix() {

// given
String directorySuffix = "test";
Expand All @@ -167,7 +167,7 @@ public void getDirectorySuffix_ReturnsDirectorySuffix() {
}

@Test
public void getDirectorySuffixWithSeparator_ReturnsDirectorySuffixWithSeparator() {
void getDirectorySuffixWithSeparator_ReturnsDirectorySuffixWithSeparator() {

// given
String directorySuffix = "test";
Expand All @@ -181,7 +181,7 @@ public void getDirectorySuffixWithSeparator_ReturnsDirectorySuffixWithSeparator(
}

@Test
public void getDirectorySuffixWithSeparatorForEmptySuffix_ReturnsEmptyString() {
void getDirectorySuffixWithSeparatorForEmptySuffix_ReturnsEmptyString() {

// given
Configuration configuration = new Configuration(outputDirectory, projectName);
Expand All @@ -191,7 +191,7 @@ public void getDirectorySuffixWithSeparatorForEmptySuffix_ReturnsEmptyString() {
}

@Test
public void getQualifier_ReturnsQualifierWhenSet() {
void getQualifier_ReturnsQualifierWhenSet() {

// given
String jsonFile = "test";
Expand All @@ -206,7 +206,7 @@ public void getQualifier_ReturnsQualifierWhenSet() {
}

@Test
public void getQualifier_ReturnsNullWhenNotSet() {
void getQualifier_ReturnsNullWhenNotSet() {

// given
String jsonFile = "test";
Expand All @@ -217,7 +217,7 @@ public void getQualifier_ReturnsNullWhenNotSet() {
}

@Test
public void getQualifier_ReturnsNullWhenSetThenRemoved() {
void getQualifier_ReturnsNullWhenSetThenRemoved() {

// given
String jsonFile = "test";
Expand All @@ -233,7 +233,7 @@ public void getQualifier_ReturnsNullWhenSetThenRemoved() {
}

@Test
public void isQualifierSet_ReturnsTrueWhenSet() {
void isQualifierSet_ReturnsTrueWhenSet() {

// given
String jsonFile = "test";
Expand All @@ -248,7 +248,7 @@ public void isQualifierSet_ReturnsTrueWhenSet() {
}

@Test
public void isQualifierSet_ReturnsTrueWhenNotSet() {
void isQualifierSet_ReturnsTrueWhenNotSet() {

// given
String jsonFile = "test";
Expand All @@ -259,7 +259,7 @@ public void isQualifierSet_ReturnsTrueWhenNotSet() {
}

@Test
public void isQualifierSet_ReturnsTrueWhenSetThenRemoved() {
void isQualifierSet_ReturnsTrueWhenSetThenRemoved() {

// given
String jsonFile = "test";
Expand All @@ -275,7 +275,7 @@ public void isQualifierSet_ReturnsTrueWhenSetThenRemoved() {
}

@Test
public void getTagsToExcludeFromChart_addPatterns_ReturnsListWithAllPatterns() {
void getTagsToExcludeFromChart_addPatterns_ReturnsListWithAllPatterns() {

// given
Configuration configuration = new Configuration(outputDirectory, projectName);
Expand All @@ -291,7 +291,7 @@ public void getTagsToExcludeFromChart_addPatterns_ReturnsListWithAllPatterns() {
}

@Test
public void setTagsToExcludeFromChart_OnInvalidRegexPattern_ThrowsValidationException() {
void setTagsToExcludeFromChart_OnInvalidRegexPattern_ThrowsValidationException() {

// given
Configuration configuration = new Configuration(outputDirectory, projectName);
Expand All @@ -301,7 +301,7 @@ public void setTagsToExcludeFromChart_OnInvalidRegexPattern_ThrowsValidationExce
}

@Test
public void addClassifications_AddsClassification() {
void addClassifications_AddsClassification() {

// given
Configuration configuration = new Configuration(outputDirectory, projectName);
Expand All @@ -319,7 +319,7 @@ public void addClassifications_AddsClassification() {
}

@Test
public void setSortingMethod_SetsSortingMethod() {
void setSortingMethod_SetsSortingMethod() {

// given
Configuration configuration = new Configuration(outputDirectory, projectName);
Expand All @@ -333,7 +333,7 @@ public void setSortingMethod_SetsSortingMethod() {
}

@Test
public void addReducingMethod_AddsReducingMethod() {
void addReducingMethod_AddsReducingMethod() {

// given
Configuration configuration = new Configuration(outputDirectory, projectName);
Expand All @@ -347,7 +347,7 @@ public void addReducingMethod_AddsReducingMethod() {
}

@Test
public void containsReducingMethod_ChecksExistenceOfReducingMethod() {
void containsReducingMethod_ChecksExistenceOfReducingMethod() {

// given
Configuration configuration = new Configuration(outputDirectory, projectName);
Expand All @@ -361,7 +361,7 @@ public void containsReducingMethod_ChecksExistenceOfReducingMethod() {
}

@Test
public void addPresentationMode_AddsPresentationMode() {
void addPresentationMode_AddsPresentationMode() {

// given
Configuration configuration = new Configuration(outputDirectory, projectName);
Expand All @@ -375,7 +375,7 @@ public void addPresentationMode_AddsPresentationMode() {
}

@Test
public void addClassificationFiles_addsPropertyFiles() {
void addClassificationFiles_addsPropertyFiles() {

// given
Configuration configuration = new Configuration(outputDirectory, projectName);
Expand All @@ -396,7 +396,7 @@ public void addClassificationFiles_addsPropertyFiles() {
}

@Test
public void getNotFailingStatuses_ReturnsNotFailingStatuses() {
void getNotFailingStatuses_ReturnsNotFailingStatuses() {

// given
Configuration configuration = new Configuration(outputDirectory, projectName);
Expand All @@ -411,7 +411,7 @@ public void getNotFailingStatuses_ReturnsNotFailingStatuses() {
}

@Test
public void setNotFailingStatuses_SkipsNullValues() {
void setNotFailingStatuses_SkipsNullValues() {

// given
Configuration configuration = new Configuration(outputDirectory, projectName);
Expand All @@ -426,7 +426,7 @@ public void setNotFailingStatuses_SkipsNullValues() {
}

@Test
public void addCustomCssFiles_addsPropertyFiles() {
void addCustomCssFiles_addsPropertyFiles() {

// given
Configuration configuration = new Configuration(outputDirectory, projectName);
Expand All @@ -443,7 +443,7 @@ public void addCustomCssFiles_addsPropertyFiles() {
}

@Test
public void addCustomJsFiles_addsPropertyFiles() {
void addCustomJsFiles_addsPropertyFiles() {

// given
Configuration configuration = new Configuration(outputDirectory, projectName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* @author Damian Szczepanik (damianszczepanik@github)
*/
public class EmptyReportableTest {
class EmptyReportableTest {

@Test
public void allMethods_ReturnsDefaultValues() {
void allMethods_ReturnsDefaultValues() {

// given
EmptyReportable reportable = new EmptyReportable();
Expand Down
Loading

0 comments on commit 1633776

Please sign in to comment.