You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you run Open Liberty in https://openliberty.io/docs/latest/development-mode.html[dev mode^], dev mode listens for file changes and automatically recompiles and deploys your updates whenever you save a new change. Run the following goal to start Open Liberty in dev mode:
113
112
114
-
ifndef::cloud-hosted[]
115
-
Navigate back to the `start` directory.
116
-
endif::[]
113
+
include::{common-includes}/os-tabs.adoc[]
117
114
118
-
ifdef::cloud-hosted[]
119
-
Open a new command-line session.
120
-
endif::[]
115
+
[.tab_content.windows_section]
116
+
--
117
+
[role='command']
118
+
```
119
+
mvnw.cmd -f inventory\pom.xml liberty:dev
120
+
```
121
+
--
122
+
123
+
[.tab_content.mac_section]
124
+
--
125
+
[role='command']
126
+
```
127
+
./mvnw -f inventory/pom.xml liberty:dev
128
+
```
129
+
--
130
+
131
+
[.tab_content.linux_section]
132
+
--
133
+
[role='command']
134
+
```
135
+
./mvnw -f inventory/pom.xml liberty:dev
136
+
```
137
+
--
138
+
139
+
After you see the following message, your Liberty instance is ready in dev mode:
Dev mode holds your command-line session to listen for file changes. Open another command-line session to continue, or open the project in your editor.
The Pact framework provides a [hotspot=pactPlugin file=1]`Maven` plugin that can be added to the build section of the `pom.xml` file. The [hotspot=serviceProvider file=1]`serviceProvider` element defines the endpoint URL for the `system` microservice and the [hotspot=pactDirectory file=1]`pactFileDirectory` directory where you want to store the pact file. The [hotspot=pactJunit file=1]`pact-jvm-consumer-junit` dependency provides the base test class that you can use with JUnit to build unit tests.
179
+
The Pact framework provides a [hotspot=pactPlugin file=1]`maven` plugin that can be added to the build section of the `pom.xml` file. The [hotspot=serviceProvider file=1]`serviceProvider` element defines the endpoint URL for the `system` microservice and the [hotspot=pactDirectory file=1]`pactFileDirectory` directory where you want to store the pact file. The [hotspot=pactJunit file=1]`pact-jvm-consumer-junit` dependency provides the base test class that you can use with JUnit to build unit tests.
153
180
154
181
After you create the `InventoryPactIT.java` class and replace the `pom.xml` file, Open Liberty automatically reloads its configuration.
155
182
@@ -171,7 +198,7 @@ When completed, you'll see a similar output to the following example:
When you integrate the Pact framework in a CI/CD build pipeline, you can use the `mvn failsafe:integration-test` goal to generate the pact file. The Maven failsafe plug-in provides a lifecycle phase for running integration tests that run after unit tests. By default, it looks for classes that are suffixed with `IT`, which stands for Integration Test. You can refer to the https://maven.apache.org/surefire/maven-failsafe-plugin/[Maven failsafe plug-in documentation^] for more information.
201
+
When you integrate the Pact framework in a CI/CD build pipeline, you can use the Maven `failsafe:integration-test` goal to generate the pact file. The Maven `failsafe` plug-in provides a lifecycle phase for running integration tests that run after unit tests. By default, it looks for classes that are suffixed with `IT`, which stands for Integration Test. You can refer to the https://maven.apache.org/surefire/maven-failsafe-plugin/[Maven failsafe plug-in documentation^] for more information.
175
202
176
203
The generated pact file is named `Inventory-System.json` and is located in the `inventory/target/pacts` directory. The pact file contains the defined interactions in JSON format:
177
204
@@ -209,22 +236,44 @@ The generated pact file is named `Inventory-System.json` and is located in the `
209
236
----
210
237
211
238
ifndef::cloud-hosted[]
212
-
Now, navigate to the `start/inventory` directory again.
239
+
Now, navigate to the `start` directory again.
213
240
endif::[]
214
241
215
242
ifdef::cloud-hosted[]
216
-
Open a new command-line session and navigate to the `start/inventory` directory.
243
+
Open a new command-line session and navigate to the `start` directory.
217
244
218
245
```bash
219
-
cd /home/project/guide-contract-testing/start/inventory
246
+
cd /home/project/guide-contract-testing/start
220
247
```
221
248
endif::[]
222
249
223
250
Publish the generated pact file to the Pact Broker by running the following command:
251
+
252
+
include::{common-includes}/os-tabs.adoc[]
253
+
254
+
[.tab_content.windows_section]
255
+
--
256
+
[role='command']
257
+
```
258
+
mvnw.cmd -f inventory\pom.xml pact:publish
259
+
```
260
+
--
261
+
262
+
[.tab_content.mac_section]
263
+
--
264
+
[role='command']
265
+
```
266
+
./mvnw -f inventory/pom.xml pact:publish
267
+
```
268
+
--
269
+
270
+
[.tab_content.linux_section]
271
+
--
224
272
[role='command']
225
273
```
226
-
mvn pact:publish
274
+
./mvnw -f inventory/pom.xml pact:publish
227
275
```
276
+
--
228
277
229
278
After the file is published, you'll see a similar output to the following example:
230
279
[role="no_copy"]
@@ -272,19 +321,41 @@ image::pact-broker-interactions.png[Pact Broker webpage for Interactions,width=9
272
321
== Implementing pact testing in the system service
273
322
274
323
275
-
Open another command-line session and navigate to the `start/system` directory.
324
+
Open another command-line session and navigate to the `start` directory.
276
325
277
326
ifdef::cloud-hosted[]
278
327
```bash
279
-
cd /home/project/guide-contract-testing/start/system
328
+
cd /home/project/guide-contract-testing/start
280
329
```
281
330
endif::[]
282
331
283
332
Start Open Liberty in dev mode for the `system` microservice:
284
-
[role=command]
333
+
334
+
include::{common-includes}/os-tabs.adoc[]
335
+
336
+
[.tab_content.windows_section]
337
+
--
338
+
[role='command']
339
+
```
340
+
mvnw.cmd -f system\pom.xml liberty:dev
341
+
```
342
+
--
343
+
344
+
[.tab_content.mac_section]
345
+
--
346
+
[role='command']
347
+
```
348
+
./mvnw -f system/pom.xml liberty:dev
349
+
```
350
+
--
351
+
352
+
[.tab_content.linux_section]
353
+
--
354
+
[role='command']
285
355
```
286
-
mvn liberty:dev
356
+
./mvnw -f system/pom.xml liberty:dev
287
357
```
358
+
--
288
359
289
360
After you see the following message, your Liberty instance is ready in dev mode:
290
361
@@ -296,7 +367,7 @@ After you see the following message, your Liberty instance is ready in dev mode:
296
367
{empty} +
297
368
298
369
ifndef::cloud-hosted[]
299
-
Open another command-line session and navigate back to the `start` directory to continue.
370
+
Open another command-line session and navigate to the `start` directory to continue.
300
371
endif::[]
301
372
302
373
ifdef::cloud-hosted[]
@@ -347,7 +418,7 @@ After you create the `SystemBrokerIT.java` class and replace the `pom.xml` file,
347
418
348
419
== Verifying the contract
349
420
350
-
In the command-line session where you started the `system` microservice, press the `enter/return` key to run the tests to verify the pact file. When you integrate the Pact framework into a CI/CD build pipeline, you can use the `mvn failsafe:integration-test` goal to verify the pact file from the Pact Broker.
421
+
In the command-line session where you started the `system` microservice, press the `enter/return` key to run the tests to verify the pact file. When you integrate the Pact framework into a CI/CD build pipeline, you can use the Maven `failsafe:integration-test` goal to verify the pact file from the Pact Broker.
351
422
352
423
The tests fail with the following errors:
353
424
[role="no_copy"]
@@ -436,7 +507,7 @@ endif::[]
436
507
437
508
[role='command']
438
509
```
439
-
docker-compose -f "pact-broker/docker-compose.yml" down
510
+
dockercompose -f "pact-broker/docker-compose.yml" down
0 commit comments