hello everyone After successfully running the test...
# pact-jvm
k
hello everyone After successfully running the test, pact json for the provider side doesn't gets generated. It just create a empty folder below is my pom.xml
Copy code
<dependency>
			<groupId>au.com.dius.pact.consumer</groupId>
			<artifactId>junit5</artifactId>
			<version>4.2.17</version>
			<scope>test</scope>
		</dependency>
m
you will need to provide some more information Kuntol.
see howtorepro
k
@Matt (pactflow.io / pact-js / pact-go) Kindly let me know what other information are required
m
1. Ideally, a project that we can clone that demonstrates the problem 2. What other relevant dependencies are you using 3. DEBUG level console output / logs is always a good start 4. What does your consumer test look like? 5. What have you tried already? Have you looked at working examples to create your test? Did it ever work?
k
My test are working but the pact json is not getting generated
m
Think about it from our end. You have told us one dependency you use and that pact files aren’t being generated. Maybe they are, and they are in a different folder. Maybe your pact tests aren’t executing
that’s a start - how do you know they are working?
k
on executing them no errors are observed also the assertion is not getting failed
m
how do you know they are running?
k
while executing the test using the option run as junit in eclipse
m
ok, so the tests are running (we think)
k
also the assertion condition is set to check the expected and actual json
which is not getting failed
m
are you sure the file is not getting generated elsewhere? Have you tried from the command line?
In any case, please share logs, that will help us see if it got written and where it got written to
k
Copy code
14:19:36.206 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
14:19:36.222 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
14:19:36.263 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.rahulshettyacademy.PactConsumerTest] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
14:19:36.278 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.rahulshettyacademy.PactConsumerTest], using SpringBootContextLoader
14:19:36.283 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.rahulshettyacademy.PactConsumerTest]: class path resource [com/rahulshettyacademy/PactConsumerTest-context.xml] does not exist
14:19:36.284 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.rahulshettyacademy.PactConsumerTest]: class path resource [com/rahulshettyacademy/PactConsumerTestContext.groovy] does not exist
14:19:36.284 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.rahulshettyacademy.PactConsumerTest]: no resource found for suffixes {-context.xml, Context.groovy}.
14:19:36.285 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.rahulshettyacademy.PactConsumerTest]: PactConsumerTest does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
14:19:36.338 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.rahulshettyacademy.PactConsumerTest]
14:19:36.413 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [C:\Users\inkbane\Test\Pact_Testing_demo\Code Projects\SpringBootRestService\target\classes\com\rahulshettyacademy\SpringBootRestServiceApplication.class]
14:19:36.415 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration com.rahulshettyacademy.SpringBootRestServiceApplication for test class com.rahulshettyacademy.PactConsumerTest
14:19:36.535 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [com.rahulshettyacademy.PactConsumerTest]: using defaults.
14:19:36.535 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.event.ApplicationEventsTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener]
14:19:36.556 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@6bab2585, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@74bdc168, org.springframework.test.context.event.ApplicationEventsTestExecutionListener@644c78d4, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@532a02d9, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@611f8234, org.springframework.test.context.support.DirtiesContextTestExecutionListener@7bb3a9fe, org.springframework.test.context.transaction.TransactionalTestExecutionListener@7cbee484, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@7f811d00, org.springframework.test.context.event.EventPublishingTestExecutionListener@62923ee6, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@4089713, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@f19c9d2, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@7807ac2c, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@b91d8c4, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@4b6166aa, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener@a77614d]
14:19:36.561 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@66ea1466 testClass = PactConsumerTest, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@1601e47 testClass = PactConsumerTest, locations = '{}', classes = '{class com.rahulshettyacademy.SpringBootRestServiceApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@6179e425, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@67304a40, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@69653e16, org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@550a1967, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@10b9db7b, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@43195e57], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true]], class annotated with @DirtiesContext [false] with mode [null].
14:19:36.607 [main] DEBUG org.springframework.test.context.support.TestPropertySourceUtils - Adding inlined properties to environment: {spring.jmx.enabled=false, org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.5.2)

2023-08-29 14:19:36.901  WARN 8020 --- [           main] ory$DuplicateJsonObjectContextCustomizer : 

Found multiple occurrences of org.json.JSONObject on the class path:

	jar:file:/C:/Users/inkbane/.m2/repository/org/json/json/20160212/json-20160212.jar!/org/json/JSONObject.class
	jar:file:/C:/Users/inkbane/.m2/repository/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar!/org/json/JSONObject.class

You may wish to exclude one of them to ensure predictable runtime behavior

2023-08-29 14:19:36.923  INFO 8020 --- [           main] com.rahulshettyacademy.PactConsumerTest  : Starting PactConsumerTest using Java 17.0.8 on VI219488 with PID 8020 (started by inkbane in C:\Users\inkbane\Test\Pact_Testing_demo\Code Projects\SpringBootRestService)
2023-08-29 14:19:36.925  INFO 8020 --- [           main] com.rahulshettyacademy.PactConsumerTest  : No active profile set, falling back to default profiles: default
2023-08-29 14:19:37.611  INFO 8020 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2023-08-29 14:19:37.692  INFO 8020 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 70 ms. Found 1 JPA repository interfaces.
2023-08-29 14:19:38.357  INFO 8020 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2023-08-29 14:19:38.644  INFO 8020 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2023-08-29 14:19:38.719  INFO 8020 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2023-08-29 14:19:38.794  INFO 8020 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.32.Final
2023-08-29 14:19:39.017  INFO 8020 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2023-08-29 14:19:39.205  INFO 8020 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2023-08-29 14:19:39.828  INFO 8020 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2023-08-29 14:19:39.837  INFO 8020 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2023-08-29 14:19:40.464  WARN 8020 --- [           main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2023-08-29 141942.796 INFO 8020 --- [ main] a.c.d.p.c.junit5.PactConsumerTestExt : Writing pacts out to default directory 2023-08-29 141943.348 INFO 8020 --- [ionShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' 2023-08-29 141943.348 INFO 8020 --- [ionShutdownHook] .SchemaDropperImpl$DelayedDropActionImpl : HHH000477: Starting delayed evictData of schema as part of SessionFactory shut-down' 2023-08-29 141943.357 INFO 8020 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... 2023-08-29 141943.360 INFO 8020 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
how to check using command line?
s
as a consumer, it can generate the json file then publish to pact broker server. as a producer, it will only validate the contract in the pact broker server.
m
Writing pacts out to default directory
so it thinks it’s writing the pacts. Where have you checked for the pact files?
s
to check using command line... 1. go to the root of your project 2. for maven : mvnw test for gradle : gradlew test
☝️ 1
m
it should be in something like
build/pacts
but I’ve seen it in the
target
directory. Search for
pacts
in the root of your project
k
It's creating a pacts folder but it's empty
m
What is this? It looks like the pact file, but rendered as a folder
are you sure it’s not the pact file, and Eclipse is just showing it funny?
Can you please try running from the command line (both the tests, and checking if the file is written).
It could be some other process clearing the pacts
s
i think he added/modified @PactFolder
👍 1
k
issue sorted the issue is with eclipse
m
What was the issue?
k
the issue is with eclipse, the json file is getting hidden
😆 2
🎉 1