Skip to content
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
44 changes: 37 additions & 7 deletions .github/workflows/jgiven_branch_and_pr_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: Java CI with Gradle
on: [push, pull_request]

jobs:
build:
name: Build JGiven on Java ${{ matrix.java }} with JUnit ${{ matrix.junit }}
junit5:
name: Build JGiven on Java ${{ matrix.java }} with JUnit 5
runs-on: ubuntu-latest
env:
ANDROID: true
strategy:
matrix:
java: [ '17', '21']
junit: [ '5.14.3', '6.0.0' ]
junit5: [ '5.11.4', '5.12.2', '5.13.4' ]
steps:
- name: Ensure chrome is installed
run: wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && sudo apt install ./google-chrome-stable_current_amd64.deb && rm *.deb
Expand All @@ -22,17 +22,47 @@ jobs:
distribution: 'adopt'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle and JUnit ${{ matrix.junit }}
run: "./gradlew -i -s check -PjunitVersion=${{ matrix.junit }}"
- name: Build with Gradle and JUnit 5 ${{ matrix.junit5 }}
run: "./gradlew -i -s check -Pjunit5Version=${{ matrix.junit5 }}"
Comment thread
l-1squared marked this conversation as resolved.
- name: Run Jacoco
Comment on lines +25 to 27
if: ${{matrix.java == '17' && github.ref == 'refs/heads/master' && github.head_ref == null}}
if: ${{matrix.java == '17' && matrix.junit5 == '5.13.4' && github.ref == 'refs/heads/master' && github.head_ref == null}}
run: ./gradlew overallJacocoReport coveralls
- name: Upload test results html files
continue-on-error: true
if: ${{failure()}}
uses: actions/upload-artifact@v7.0.1
with:
name: test-report_${{matrix.java}}_${{matrix.junit}}
name: test-report_junit5-${{matrix.junit5}}_java${{matrix.java}}
path: /home/runner/work/JGiven/JGiven/*/build/reports/tests
if-no-files-found: ignore
junit6:
name: Build JGiven on Java ${{ matrix.java }} with JUnit 6
runs-on: ubuntu-latest
env:
ANDROID: true
strategy:
matrix:
java: [ '17', '21' ]
junit6: [ '6.0.0', '6.0.3' ]
steps:
- name: Ensure chrome is installed
run: wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && sudo apt install ./google-chrome-stable_current_amd64.deb && rm *.deb
- uses: actions/checkout@v6.0.2
- name: Set up JDK ${{matrix.java}}
uses: actions/setup-java@v5.2.0
with:
java-version: ${{matrix.java}}
distribution: 'adopt'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle and JUnit 6 ${{ matrix.junit6 }}
run: "./gradlew -i -s check -Pjunit6Version=${{ matrix.junit6 }}"
- name: Upload test results html files
continue-on-error: true
if: ${{failure()}}
uses: actions/upload-artifact@v7.0.1
with:
name: test-report_junit6-${{matrix.junit6}}_java${{matrix.java}}
path: /home/runner/work/JGiven/JGiven/*/build/reports/tests
if-no-files-found: ignore
junit4:
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@

* Removed deprecated JGiven-Spock module. Please use the JGiven-Spock2 module instead.

## Deprecated modules

* Deprecated `jgiven-junit5` module in favor of `jgiven-junit6`. The `jgiven-junit6` module provides full JUnit 5 support and is also compatible with JUnit 6, enabling forward compatibility. Existing JUnit 5 tests using `jgiven-junit5` will continue to work, but new projects should use `jgiven-junit6`.
* Use `com.tngtech.jgiven.junit6.ScenarioTest`, `com.tngtech.jgiven.junit6.SimpleScenarioTest`, and `com.tngtech.jgiven.junit6.DualScenarioTest` instead of the junit5 variants.

* Deprecated `jgiven-spring-junit5` module for Spring 7.x compatibility. A new `jgiven-spring-junit6` module has been introduced that supports Spring 7.x.
* The `jgiven-spring-junit5` module will continue to support Spring 6.x but is deprecated for users wanting to upgrade to Spring 7.x or later.
* Use `com.tngtech.jgiven.integration.spring.junit6.SpringScenarioTest`, `com.tngtech.jgiven.integration.spring.junit6.SimpleSpringScenarioTest`, and `com.tngtech.jgiven.integration.spring.junit6.DualSpringScenarioTest` instead of the junit5 variants.
Comment thread
l-1squared marked this conversation as resolved.

## New features

* Added `jgiven-junit6` module with support for both JUnit 5 and JUnit 6. This module provides API compatibility with JUnit 5 and enables migration to JUnit 6 when ready.
* Added `jgiven-spring-junit6` module with support for Spring 7.x while maintaining backward compatibility with JUnit 5.

# Release v2.0.3

## Fixed issues
Expand Down
5 changes: 0 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ configure(subprojects.findAll { !it.name.contains("android") }) {
testImplementation libs.slf4j.java.util.logging
testImplementation libs.assertj
testImplementation libs.quickcheck

if (rootProject.hasProperty('junitVersion')) {
// Use dynamic JUnit version for testing
testImplementation platform("org.junit:junit-bom:${rootProject.junitVersion}")
}
}

if (timingEnabled) {
Expand Down
32 changes: 24 additions & 8 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ gson-version = "2.14.0"
guava-version = "33.6.0-jre"
jakarta-version = "3.0.0"
junit4-version = "4.13.2"
junit5-version = "5.13.4"
junit6-version = "6.1.0"
mockito-version = "5.23.0"
paranamer-version = "2.8.3"
slf4j-version = "2.0.18"
spring-version = "6.2.19"
spring6-version = "6.2.18"
spring7-version = "7.0.6"
androidx-test-version = "1.7.0"
vanniktech-version = "0.36.0"

Expand All @@ -28,7 +31,8 @@ gson = { module = "com.google.code.gson:gson", version.ref = "gson-version" }
guava = { module = "com.google.guava:guava", version.ref = "guava-version" }
hypersql-database = { module = "org.hsqldb:hsqldb", version = "2.7.4" }
jakarta-annotation = { module = "jakarta.annotation:jakarta.annotation-api", version.ref = "jakarta-version" }
junit-bom = { module = "org.junit:junit-bom", version = "6.1.0" }
junit6-bom = { module = "org.junit:junit-bom", version.ref = "junit6-version" }
junit5-bom = { module = "org.junit:junit-bom", version.ref = "junit5-version" }
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter" }
junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher" }
junit4 = { module = "junit:junit", version.ref = "junit4-version" }
Expand All @@ -40,17 +44,29 @@ publish = { module = "com.vanniktech.maven.publish:com.vanniktech.maven.publish.
quickcheck = { module = "net.java.quickcheck:quickcheck", version = "0.6" }
slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j-version" }
slf4j-java-util-logging = { module = "org.slf4j:slf4j-jdk14", version.ref = "slf4j-version" }
spring-context = { module = "org.springframework:spring-context", version.ref = "spring-version" }
spring-test = { module = "org.springframework:spring-test", version.ref = "spring-version" }
spring-tx = { module = "org.springframework:spring-tx", version.ref = "spring-version" }
spring-jdbc = { module = "org.springframework:spring-jdbc", version.ref = "spring-version" }
spring6-context = { module = "org.springframework:spring-context", version.ref = "spring6-version" }
spring6-test = { module = "org.springframework:spring-test", version.ref = "spring6-version" }
spring6-tx = { module = "org.springframework:spring-tx", version.ref = "spring6-version" }
spring6-jdbc = { module = "org.springframework:spring-jdbc", version.ref = "spring6-version" }
# NOTE: Unprefixed `spring-*` libraries below resolve to Spring 7.
# Use the `spring6-*` aliases above when a module must stay on Spring 6 (e.g. jgiven-spring,
# jgiven-spring-junit4, jgiven-spring-junit5).
spring-context = { module = "org.springframework:spring-context", version.ref = "spring7-version" }
spring-test = { module = "org.springframework:spring-test", version.ref = "spring7-version" }
spring-tx = { module = "org.springframework:spring-tx", version.ref = "spring7-version" }
spring-jdbc = { module = "org.springframework:spring-jdbc", version.ref = "spring7-version" }
testng = { module = "org.testng:testng", version="7.12.0" }


[bundles]
junit4 = [ "junit4", "junit4-dataprovider", "junit4-params" ]
spring-test = [ "spring-context", "spring-test", "spring-tx", "spring-jdbc" ]
spring-compile = [ "spring-context", "spring-test" ]
# Spring 6 test bundle (used by jgiven-spring, jgiven-spring-junit4, jgiven-spring-junit5).
spring6-test = ["spring6-context", "spring6-test", "spring6-tx", "spring6-jdbc"]
# Spring 7 test bundle (used by jgiven-spring-junit6).
spring-test = ["spring-context", "spring-test", "spring-tx", "spring-jdbc"]
# `spring-compile` is intentionally Spring 6: published modules compile against Spring 6
# APIs to remain ABI-compatible with Spring 6 consumers; Spring 7 is forward-compatible.
spring-compile = ["spring6-context", "spring6-test"]
aspectj-spring-test = [ "aspectj-jrt", "aspectj-jweaver" ]

[plugins]
4 changes: 2 additions & 2 deletions jgiven-future-java-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ java {

dependencies {
testImplementation(project(":jgiven-core"))
testImplementation(project(":jgiven-junit5"))
testImplementation(project(":jgiven-junit6"))
testImplementation(project(":jgiven-html5-report"))

implementation(platform(libs.junit.bom))
implementation(platform(libs.junit6.bom))

testImplementation("org.junit.jupiter:junit-jupiter-engine")
testImplementation("org.junit.jupiter:junit-jupiter-params")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.tngtech.jgiven.tests.sealed;

import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import com.tngtech.jgiven.Stage;
import com.tngtech.jgiven.junit5.SimpleScenarioTest;
import java.util.Collections;
import com.tngtech.jgiven.junit6.SimpleScenarioTest;
import org.junit.jupiter.api.Test;

import java.util.Collections;

import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

class SealedClassesHandlingTest {

@Test
Expand Down
2 changes: 1 addition & 1 deletion jgiven-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies {
implementation(project(":jgiven-core"))
implementation(project(":jgiven-asciidoc-report"))
implementation(project(":jgiven-html5-report"))
implementation(platform(libs.junit.bom))
implementation(platform(libs.junit6.bom))
implementation(libs.jakarta.annotation)
implementation(libs.guava)
implementation(libs.gson)
Expand Down
23 changes: 16 additions & 7 deletions jgiven-junit5/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
id("jgiven-java")
}

description = "Module for writing JGiven tests with JUnit 5"
description = "Module for writing JGiven tests with JUnit 5 (Deprecated: Use jgiven-junit6 for JUnit 5 and 6 support)"

tasks.withType<JavaCompile> {
options.compilerArgs.add("-parameters")
Expand All @@ -20,12 +20,12 @@ tasks.named<Test>("test") {
}

dependencies {
api(project(":jgiven-core"))
api(project(":jgiven-junit6"))

if (rootProject.hasProperty("junitVersion")) {
implementation(platform("org.junit:junit-bom:${rootProject.property("junitVersion")}"))
if (rootProject.hasProperty("junit5Version")) {
implementation(platform("org.junit:junit-bom:${rootProject.property("junit5Version")}"))
} else {
implementation(platform(libs.junit.bom))
implementation(platform(libs.junit5.bom))
}
compileOnly("org.junit.jupiter:junit-jupiter-params")
compileOnly("org.junit.jupiter:junit-jupiter-api")
Expand All @@ -38,6 +38,10 @@ dependencies {

val generatedSourceDir = "generatedSrc/java"

tasks.named<Delete>("clean") {
delete(generatedSourceDir)
}

sourceSets {
main {
java {
Expand All @@ -47,7 +51,11 @@ sourceSets {
}

file("../jgiven-core/src/main/translations").listFiles()?.forEach { translationFile ->
val pkg = translationFile.name.split(".")[0]
if (!translationFile.isFile()) {
return@forEach
}

val pkg = translationFile.nameWithoutExtension

val props = Properties()
translationFile.inputStream().use { stream -> props.load(stream) }
Expand All @@ -56,10 +64,11 @@ file("../jgiven-core/src/main/translations").listFiles()?.forEach { translationF
val taskName = "${pkg}Translation"

val copyTask = tasks.register<Copy>(taskName) {
from("src/main/templates")
from("../jgiven-junit6/src/main/templates")
into("$generatedSourceDir/com/tngtech/jgiven/junit5/lang/$pkg")
rename("SimpleScenarioTest.template", "${props.getProperty("simple_scenario_test_class")}.java")
rename("ScenarioTest.template", "${props.getProperty("scenario_test_class")}.java")
props["module"] = "junit5"
@Suppress("UNCHECKED_CAST") // Properties has string keys!
expand(props.toMap() as Map<String, *>)
filteringCharset = "UTF-8"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,11 @@
package com.tngtech.jgiven.junit5;

import com.tngtech.jgiven.base.DualScenarioTestBase;
import com.tngtech.jgiven.impl.Scenario;
import org.junit.jupiter.api.extension.ExtendWith;


/**
* Convenience test base class for writing JGiven scenarios with JUnit 5.
* If you only have one stage class you can also use the {@link SimpleScenarioTest} class.
* If you don't want to inherit from any class you can just use the {@link JGivenExtension}
* directly.
*
* @param <GIVEN_WHEN> the combined GIVEN and WHEN stage
* @param <THEN> the THEN stage
*
* @see JGivenExtension
* @see SimpleScenarioTest
* @deprecated As of JGiven 3.0.0, use {@link com.tngtech.jgiven.junit6.DualScenarioTest} instead.
* The junit6 module supports both JUnit 5 and JUnit 6.
*/
@ExtendWith( JGivenExtension.class )
public class DualScenarioTest<GIVEN_WHEN, THEN> extends DualScenarioTestBase<GIVEN_WHEN, THEN> {
@Deprecated(since = "3.0.0", forRemoval = false)
public class DualScenarioTest<GIVEN_WHEN, THEN> extends com.tngtech.jgiven.junit6.DualScenarioTest<GIVEN_WHEN, THEN> {
}

private Scenario<GIVEN_WHEN,GIVEN_WHEN, THEN> scenario = createScenario();

@Override
public Scenario<GIVEN_WHEN, GIVEN_WHEN, THEN> getScenario() {
return scenario;
}
}
Loading