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
Copy file name to clipboardExpand all lines: README.md
+19-11Lines changed: 19 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,11 +2,13 @@
2
2
3
3
## What's New? ##
4
4
5
-
* The latest version ([Tcases 3.4.2](ReleaseNotes.md#342)) is now available at the Maven Central Repository.
5
+
* The latest version ([Tcases 3.5.0](ReleaseNotes.md#350)) is now available at the Maven Central Repository.
6
6
See [*How To Download Tcases*](HowToDownload.md) for download instructions.
7
7
8
-
* Tcases 3.4.2 provide improvements for several Tcases components.
9
-
See the [release notes](ReleaseNotes.md#342) for details.
8
+
* Tcases 3.5.0 introduces a new capability to Tcases for OpenAPI: generating API tests using the examples defined in an OpenAPI v3 spec.
9
+
And other improvements, too -- see the [release notes](ReleaseNotes.md#350) for details.
10
+
11
+
* Having trouble with Tcases? Check out [these tips](./Troubleshooting-FAQs.md).
10
12
11
13
* Subscribe to the [Tcases Forum](https://groups.google.com/d/forum/tcases) group to get notifications and share experiences with other Tcases users.
12
14
@@ -38,14 +40,20 @@ JUnit or TestNG test class.
38
40
39
41
## Get Started! ##
40
42
41
-
*[Tcases: The Complete Guide](http://www.cornutum.org/tcases/docs/Tcases-Guide.htm)
42
-
*[Tcases: The JSON Guide](http://www.cornutum.org/tcases/docs/Tcases-Json.htm): A companion to _The Complete Guide_ adding info specific to JSON
43
-
*[Tcases for OpenAPI](tcases-openapi/README.md#tcases-for-openapi-from-rest-ful-to-test-ful): Testing a REST-ful API? Generate test cases directly from your OpenAPI v3 spec.
*[Tcases: The Complete Guide](http://www.cornutum.org/tcases/docs/Tcases-Guide.htm)
45
+
*[Tcases: The JSON Guide](http://www.cornutum.org/tcases/docs/Tcases-Json.htm): A companion to _The Complete Guide_ adding info specific to JSON
46
+
*[Tcases for OpenAPI](tcases-openapi/README.md#tcases-for-openapi-from-rest-ful-to-test-ful): Testing a REST-ful API? Generate test cases directly from your OpenAPI v3 spec.
# Generate tests for requests, using example data defined by my-api.(json,yaml).
342
+
# (See 'OpenAPI tips, For example test cases'.)
343
+
mvn tcases:api -Dproject=my-api -Dsource=examples
344
+
```
345
+
311
346
312
347
## Semantic linting with Tcases for OpenAPI ##
313
348
@@ -418,6 +453,37 @@ To use Tcases for OpenAPI effectively, there are some things to keep in mind whe
418
453
they imply a very large and complex input space. (Probably much more than was actually intended!) Fortunately, it's easy to avoid them. In cases where
419
454
different types of values are actually expected, you can define this explicitly using the `oneOf` keyword.
420
455
456
+
1. **For example test cases, make your <A name="example-tips">examples</A> complete.** You can generate test cases
457
+
using the [examples](#examples) defined in your OpenAPI spec, but only if an example is defined for every
458
+
input data item. Fortunately, there are lots of ways to do that.
459
+
460
+
* You can do it explicitly at a high level, by defining the `examples` or `example` field
461
+
for a request parameter or a `content` object.
462
+
463
+
* You can do it explicitly at a lower level, by defining the `example` field of a schema.
464
+
465
+
* For an `object` schema, you don't need a top-level `example` if example data is defined for each property schema.
466
+
467
+
* Similarly, for an `array` schema, you don't need a top-level `example` if example data is defined for the `items` schema.
468
+
469
+
* For a schema that uses `enum` to list valid data, no other examples are necessary.
470
+
471
+
* For a `boolean` schema, only `true` and `false` are valid, so no other examples are necessary.
472
+
473
+
* For a basic type schema (`integer`, `number`, or `string`), if no `example` is defined, the `default` data value is used
474
+
instead.
475
+
476
+
* What about a schema that is based on boolean combinations of sub-schemas (e.g. `allOf`, `oneOf`, etc.)? If no `example` is defined
477
+
explicitly, can example data be assembled from the sub-schemas? Yes, but only under certain conditions. The basic rule is that
478
+
example data can be assembled only if it is not required to satisfy two or more different sets of assertions. Therefore, example
479
+
data can be assembled from sub-schemas only if:
480
+
481
+
* there is no `not` assertion,
482
+
* there is no `allOf` assertion,
483
+
* there is either an `anyOf` or a `oneOf` assertion but not both,
484
+
* and if `anyOf` or `oneOf` is specified, it is the only schema assertion.
485
+
486
+
421
487
## Test case generation tips ##
422
488
423
489
1. **Handle input modelling <A name="conditions">conditions</A>.** Tcases for OpenAPI reports conditions in your OpenAPI spec that will affect how test cases are generated. Warning conditions are reported with an explanation of the situation. Error conditions report elements in your spec that may need to be changed to generate tests correctly. By default, conditions are reported by writing log messages. By specifying a different [`ModelConditionNotifier`](http://www.cornutum.org/tcases/docs/api/org/cornutum/tcases/openapi/ModelConditionNotifier.html), you can cause these conditions to throw an exception or to be completely ignored. You can do this at the command line using the `-c` option of the `tcases-api` command. You can even customize condition handling using your own implementation of the `ModelConditionNotifier` interface in the [`ModelOptions`](http://www.cornutum.org/tcases/docs/api/org/cornutum/tcases/openapi/ModelOptions.html) used by Tcases for OpenAPI.
0 commit comments