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
- Move `postmanEnvJSONFormat()` to PostmanEnvironment
- Add `getTypedObj()` to PostmanEnvironment
- Add infix overload for `getTypedTxnObj()` in TxnInfo
Signed-off-by: Gopal S Akshintala <gopala.akshintala@salesforce.com>
<12> <<#_type_safety_with_flexible_json_pojo_marshallingserialization_and_unmarshallingdeserialization, Global Custom Type Adapters>>
333
333
<13> Ignore Java cert issues when firing HTTP calls
@@ -406,33 +406,45 @@ The configuration offers methods through which the execution strategy can be con
406
406
* `runOnlySteps`, `skipSteps` — All these accept a `predicate` of type `ExeStepPick`, which is invoked passing the current `Step` instance to decide whether to execute or skip a step.
407
407
** There are some `ExeStepPick` predicates bundled with ReṼoman under `ExeStepPick.PickUtils` e.g `withName`, `inFolder` etc. You can write a custom predicate of your own too.
408
408
409
-
[#_pre_and_post_step_hooks]
410
-
=== Pre- and Post-Step Hooks
409
+
[#_pre_step_and_post_step_hooks]
410
+
=== Pre-Step and Post-Step Hooks
411
411
412
412
A hook lets you fiddle with the execution by plugging in your code before or after a Step execution.
413
413
414
414
[#_step_picks]
415
-
You can pass a `PreTxnStepPick/PostTxnStepPick` which is a `Predicate` used to qualify a step for Pre-/Post-Hook respectively. ReṼoman comes bundled with some predicates under the namespace `PreTxnStepPick.PickUtils/PostTxnStepPick.PickUtils` e.g `beforeStepContainingURIPathOfAny`, `afterStepName` etc. If those don't fit your needs, you can write your own custom predicates too.
415
+
You can pass a `PreTxnStepPick/PostTxnStepPick` which is a `Predicate` used
416
+
to qualify a step for Pre-Step/Post-Step Hook respectively.
417
+
ReṼoman comes
418
+
bundled with some predicates under the namespace `PreTxnStepPick.PickUtils`/`PostTxnStepPick.PickUtils` e.g `beforeStepContainingURIPathOfAny`,
419
+
`afterStepName` etc. If those don't fit your needs, you can write your own custom predicates like below:
420
+
421
+
[source,java,indent=0,options="nowrap"]
422
+
----
423
+
final var preTxnStepPick = (currentStep, requestInfo, rundown) -> LOGGER.info("Picked `preLogHook` before stepName: {}", currentStep)
424
+
final var postTxnStepPick = (stepReport, rundown) -> LOGGER.info("Picked `postLogHook` after stepName: {}", stepReport.step.displayName)
425
+
----
426
+
427
+
Add them to the config as below:
416
428
417
429
[source,java,indent=0,options="nowrap"]
418
430
----
419
431
.hooks(
420
432
pre(
421
-
PreTxnStepPick,
433
+
preTxnStepPick,
422
434
(currentStepName, requestInfo, rundown) -> {
423
-
//...callback-code...
435
+
//...code...
424
436
}),
425
437
post(
426
-
PostTxnStepPick,
438
+
postTxnStepPick,
427
439
(currentStepName, rundown) -> {
428
-
//...callback-code...
440
+
//...code...
429
441
})
430
442
)
431
443
----
432
444
433
445
You can do things like assertion on the rundown, response validation,
434
-
or environment and even <<#_mutable_environment,mutate the environment>>,
435
-
such that the execution of subsequent steps picks up those changes.
446
+
or even <<#_mutable_environment,mutate the environment>> with a value you programmatically derived,
447
+
such that the execution of later steps picks up those changes.
==== Plug-in your Java code in-between Postman execution
@@ -465,7 +477,7 @@ so the later steps can pick up value for `+{{xyzId}}+` variable from the environ
465
477
npm install moment
466
478
----
467
479
468
-
.Use inside pre- / post-script
480
+
.Use inside pre-req and post-res scripts
469
481
[source,javascript,indent=0,options="nowrap"]
470
482
----
471
483
var moment = require("moment");
@@ -491,12 +503,12 @@ CAUTION: The recommendation is not to add too much code in <<Pre-req and Post-re
491
503
=== Mutable Environment
492
504
493
505
* Environment is the only mutable-shared state across step executions, which can be used for data passing between the consumer and the library.
494
-
* This can be mutated (set key-value pairs) through <<Pre-req and Post-res scripts>> (using `pm.environment.set()`) and <<#_pre_and_post_step_hooks,Pre-/Post-Hooks>> (using the reference `rundown.mutableEnv`) during execution.
506
+
* This can be mutated (set key-value pairs) through <<Pre-req and Post-res scripts>> (using `pm.environment.set()`) and <<#_pre_step_and_post_step_hooks,Pre-/Post-Hooks>> (using the reference `rundown.mutableEnv`) during execution.
495
507
496
508
==== Read Mutable Environment as Postman Environment JSON format
497
509
498
510
You may want to troubleshoot manually with Postman using the Mutable environment built during the ReṼoman execution.
499
-
`rundown.envInPostmanEnvJSONFormat()` converts the mutable environment into a Postman JSON format,
511
+
`rundown.mutableEnv.postmanEnvJSONFormat()` converts the mutable environment into a Postman JSON format,
500
512
so you can copy and import that conveniently into Postman.
501
513
502
514
==== `pmEnvSnapshot` in each StepReport
@@ -568,13 +580,13 @@ The future looks bright with multiple impactful features in the pipeline:
568
580
569
581
=== How to Debug a step in the middle of an Execution?
570
582
571
-
* You can add a <<#_pre_and_post_step_hooks,pre-hook>> to the Step you are interested and add a debug point inside that. This gets hit before ReṼoman fires the request in that Step
583
+
* You can add a <<#_pre_step_and_post_step_hooks,pre-hook>> to the Step you are interested and add a debug point inside that. This gets hit before ReṼoman fires the request in that Step
572
584
* You can get more adventurous by attaching revoman jar sources and directly adding conditional debug points inside this library source-code. You can search for logs in the source-code that indicate key operations to add conditional debug points with conditions like StepName etc.
573
585
574
586
=== Is there a way to add Metadata to a Postman collection Step?
575
587
576
588
* You can add key-value pairs to a Step's HTTP Headers section (e.g., `ignoreHTTPStatusUnsuccessful=true`).
577
-
* You can use this information in <<#_step_picks,Step Picks>> or <<#_pre_and_post_step_hooks>> to identify a particular step to execute any conditional logic
589
+
* You can use this information in <<#_step_picks,Step Picks>> or <<#_pre_step_and_post_step_hooks>> to identify a particular step to execute any conditional logic
578
590
579
591
=== Do I need to migrate all my existing TestUtils to Postman Collections?
0 commit comments