question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pact-jvm-junit5 writes all pacts to target/pacts instead of $buildDir/pacts

See original GitHub issue

The title explains it.

Here is my build.gradle file for reference

buildscript {
	ext {
		springBootVersion = '2.0.2.RELEASE'
		pactDirectory = "$buildDir/pacts"
	}
	repositories {
		mavenCentral()
	}
	dependencies {
		classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
		classpath("org.junit.platform:junit-platform-gradle-plugin:1.1.0")
		classpath("au.com.dius:pact-jvm-provider-gradle_2.12:3.5.16")
	}
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'au.com.dius.pact'
apply plugin: 'org.junit.platform.gradle.plugin'

group = 'io.redacted'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
	mavenCentral()
}


dependencies {
	compile("org.projectlombok:lombok:1.16.16")
	compile('org.springframework.boot:spring-boot-starter-web')
	testCompile('org.springframework.boot:spring-boot-starter-test')
	testCompile('au.com.dius:pact-jvm-consumer-junit5_2.12:3.5.16')
	testRuntime("org.junit.jupiter:junit-jupiter-engine:5.1.0")
	testRuntime("org.junit.platform:junit-platform-launcher:1.1.0")
}

task wrapper(type: Wrapper) {
	gradleVersion = '4.6'
}

// Set where to put pact files
test {
	systemProperties['pact.rootDir'] = pactDirectory
}

// Publish pact files
pact {
	publish {
		pactDirectory = pactDirectory
		pactBrokerUrl = 'http://localhost:3000'
	}
}

// Push pacts to broker
build.finalizedBy(pactPublish)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
uglyogcommented, Apr 14, 2019

This fix has been released with version 3.6.4

1reaction
kekko1212commented, May 11, 2020

Hey @HaMatthias and @uglyog, I had the same issue where the pact files are actually stored in the target dir by default.

I noticed that it actually happens only when I run my pact tests using IntelliJ. If instead I run the same tests from CLI, it works correctly.

The issue is that I was running the tests using IntelliJ IDEA instead of Gradle (Default) as per screenshot (Settings > Build, Execution, Deployment > Build and Tools > Gradle) image

Changing it to Gradle worked for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pact-jvm-junit5 writes all pacts to target/pacts instead ... - GitHub
I noticed that it actually happens only when I run my pact tests using IntelliJ. If instead I run the same tests from...
Read more >
pact-jvm-consumer-junit5 | Pact Docs
By default, pact files are written to target/pacts (or build/pacts if you use Gradle), but this can be overwritten with the pact.rootDir system ......
Read more >
How to write and validate Pact contracts using JUnit5 and ...
Uncomment this and comment @PactBroker instead to test locally by pasting a .json file for the contract under the target/pacts folder */
Read more >
Pact File Not Generated Inspite of test being Passed
rootDir>src/test/resources/pacts</pact. ... Pact JVM appears to ignore the buildDirectory property. Try the following configuration:
Read more >
au.com.dius.pact.consumer : junit5 - Maven Central
To write Pact consumer tests with JUnit 5, you need to add ... pact files are written to `target/pacts` (or `build/pacts` if you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found