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

Can't set pact.verifier.publishResults to true with Maven #724

Closed
MeadowValley opened this issue Jul 2, 2018 · 10 comments
Closed

Can't set pact.verifier.publishResults to true with Maven #724

MeadowValley opened this issue Jul 2, 2018 · 10 comments

Comments

@MeadowValley
Copy link

MeadowValley commented Jul 2, 2018

Hello,

since an update I get the following warning:
[main] WARN au.com.dius.pact.provider.junit.InteractionRunner - Skipping publishing of verification results (pact.verifier.publishResults is not set to 'true')
As I found this #publishing-verification-results-to-a-pact-broker-version-354 I tried to set the property in the pom.xml in property-section, via the properties-maven-plugin and via command line (Dpact.verifier.publishResults=true), but nothing of that worked for me. I could not figure out how to set it to true.

Any ideas?

Edit: This may be a duplicate of: #538
As I use Annotations (@PactUrl) and there is no Annotation like PactBrokerUrl there may be another chance? I need an url like: "http://" + Constants.PACTBROKERHOST + ":" + Constants.PACTBROKERPORT + "/pacts/provider/" + PROVIDER + "/consumer/" + CONSUMER+ "/version/" + PACTVERSION

@rholshausen
Copy link
Contributor

The JUnit tests run by the surefire Maven plugin. You need to get it to set the property, as per http://maven.apache.org/surefire/maven-surefire-plugin/examples/system-properties.html

@SnewsButton
Copy link
Contributor

SnewsButton commented Jul 3, 2018

The value of 'true' the verifier seeks is the string "true" rather than the boolean true (see ProviderVerifier.kt) (Possible enhancement? If so, I can work on that). So that is why the way you set it via the terminal failed. That being said, when setting the property with the surefire Maven plugin, <pact.verifier.publishResults>true</pact.verifier.publishResults> suffices.

Also, this enables publishing verification results to a Pact Broker. So even if you set it to true, it has no use without a broker.

@uglyog
Copy link
Member

uglyog commented Jul 3, 2018

JVM properties are always strings. How can you supply any other type of value?

@uglyog uglyog added the question label Jul 3, 2018
@SnewsButton
Copy link
Contributor

SnewsButton commented Jul 4, 2018

I think I erred because of my general jvm unfamiliarity. Rather than setting the property through maven (which I do now), I initially set pact.verifier.publishResults to the boolean true programatically. So

Properties prop = System.getProperties();
prop.put("pact.verifier.publishResults", true);
System.setProperties(prop);

would not register as 'true', but this would:

prop.put("pact.verifier.publishResults", "true");

This is probably just my own fault.

@MeadowValley
Copy link
Author

MeadowValley commented Jul 5, 2018

Okay, this is what I have now:

...
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>${mvn-surefire-plugin.version}</version>
				<configuration>
					<systemProperties>
						<property>
							<pact.verifier.publishResults>true</pact.verifier.publishResults>
						</property>
					</systemProperties>
				</configuration>
			</plugin>
...

This is working for me.
One of my problems was that I executed my test without maven.

You can close this thread now as my issue is solved. :)
Thank you all!

@Norman-else
Copy link

@derKnecht According to your last comment:

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemProperties>
                        <property>
                            <pact.verifier.publishResults>true</pact.verifier.publishResults>
                        </property>
                    </systemProperties>
                    <includes>
                        <include>**/*Test.java</include>
                        <include>**/*Tests.java</include>
                        <include>**/*TestCase.java</include>
                        <include>**/*Spec.java</include>
                    </includes>
                </configuration>
            </plugin>

That still not work for me. Could you please help me?

@Norman-else
Copy link

ublishing verification results to a Pact Broker. So even if you set it to true, it has no use without a broker.

        <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemProperties>
                        <property>
                            <pact.verifier.publishResults>"true"</pact.verifier.publishResults>
                        </property>
                    </systemProperties>
                    <includes>
                        <include>**/*Test.java</include>
                        <include>**/*Tests.java</include>
                        <include>**/*TestCase.java</include>
                        <include>**/*Spec.java</include>
                    </includes>
                </configuration>
            </plugin>

This is my configuration but still not works no matter I change the value to 'true' or true or "true".

@uglyog
Copy link
Member

uglyog commented Jun 24, 2020

@Norman-else what version of Pact-JVM are you using?

@Dattasaisukumar
Copy link

Dattasaisukumar commented Jul 5, 2020

Hi even I am also not able to publish the results after verifying . I am getting error as publish is not set to true.

I am using this pulgin

org.apache.maven.plugins maven-surefire-plugin 3.0.0-M5 true

and my other dependency details are

au.com.dius pact-jvm-provider-junit 4.0.10 au.com.dius pact-jvm-provider-maven 4.0.10

Can anyone please help me on this. I am able to do the verification sucessfully. I want to publish my results into PACT BROKER back

I have used "true",ture,'true' nothing workedout for me :(

@uglyog
Copy link
Member

uglyog commented Jul 12, 2020

@Dattasaisukumar just check https://maven.apache.org/surefire/maven-surefire-plugin/examples/system-properties.html, systemProperties is deprecated and you should use systemPropertyVariables which has a different form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants