Skip to content

Commit 0d13202

Browse files
Release 3.5.0 (#158)
1 parent b2bc1a8 commit 0d13202

14 files changed

Lines changed: 152 additions & 23 deletions

File tree

README.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
## What's New? ##
44

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.
66
See [*How To Download Tcases*](HowToDownload.md) for download instructions.
77

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).
1012

1113
* Subscribe to the [Tcases Forum](https://groups.google.com/d/forum/tcases) group to get notifications and share experiences with other Tcases users.
1214

@@ -38,14 +40,20 @@ JUnit or TestNG test class.
3840

3941
## Get Started! ##
4042

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.
44-
* [The Tcases Maven Plugin](http://www.cornutum.org/tcases/docs/tcases-maven-plugin/)
45-
* [How To Download Using Maven](HowToDownload.md)
46-
* [Model-Driven Testing Using Tcases](ModelDrivenTestingForAgileTeams.md)
47-
* [Release Notes](ReleaseNotes.md)
48-
* Javadoc: [Tcases API](http://www.cornutum.org/tcases/docs/api/)
43+
* **The Lowdown**
44+
* [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.
47+
* [The Tcases Maven Plugin](http://www.cornutum.org/tcases/docs/tcases-maven-plugin/)
48+
49+
* **Helpful Guides**
50+
* [How To Download Using Maven](HowToDownload.md)
51+
* [Troubleshooting FAQ](./Troubleshooting-FAQs.md)
52+
* [Release Notes](ReleaseNotes.md)
53+
54+
* **More Info**
55+
* [Model-Driven Testing Using Tcases](ModelDrivenTestingForAgileTeams.md)
56+
* Javadoc: [Tcases API](http://www.cornutum.org/tcases/docs/api/)
4957

5058
## Contributors ##
5159

ReleaseNotes.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,37 @@
11
# Release Notes #
22

3+
## 3.5.0 ##
4+
5+
This release introduces a new capability to Tcases for OpenAPI: generating API tests using the
6+
[examples](./tcases-openapi/README.md#how-does-it-work) defined in an OpenAPI v3 spec.
7+
8+
Other improvements:
9+
10+
* **CLI**
11+
12+
* Want to report a problem with your input model but unable to share proprietary information?
13+
Introducing the [Tcases Anonymizer](./How-To-Anonymize.md#how-to-anonymize-your-input-model).
14+
15+
* **Tcases For OpenAPI**
16+
17+
* Fixes a defect that produced inconsistent test cases for requests with path parameters or non-nullable query
18+
parameters when the value is a simple string. [[154](https://github.com/Cornutum/tcases/issues/154)]
19+
20+
* Upgraded to swagger-parser 2.0.24
21+
22+
* **Core**
23+
24+
* Fixes a defect that caused Tcases to incorrectly claim that a required value combination is [infeasible](./Troubleshooting-FAQs.md#infeasible).
25+
In previous versions, this problem could arise when generating tests using high-level combination coverage
26+
requirements (2-tuples, 3-tuples, etc) for an input model with complex conditions.
27+
28+
* **Other**
29+
30+
* When a system input definition is written as an XML document, variable and value conditions are correctly represented using
31+
a "whenNot" attribute when possible. [[62](https://github.com/Cornutum/tcases/issues/62)]
32+
33+
* Troubleshooting tips are now consolidated in a new [Troubleshooting FAQ](./Troubleshooting-FAQs.md).
34+
335
## 3.4.2 ##
436

537
This release provides the following improvements:

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<groupId>org.cornutum.tcases</groupId>
88
<artifactId>tcases</artifactId>
99
<packaging>pom</packaging>
10-
<version>3.4.3-SNAPSHOT</version>
10+
<version>3.5.0</version>
1111

1212
<name>Tcases</name>
1313
<description>Generates test cases from system input space models</description>

tcases-ant/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.cornutum.tcases</groupId>
99
<artifactId>tcases</artifactId>
10-
<version>3.4.3-SNAPSHOT</version>
10+
<version>3.5.0</version>
1111
</parent>
1212

1313
<artifactId>tcases-ant</artifactId>

tcases-cli/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.cornutum.tcases</groupId>
99
<artifactId>tcases</artifactId>
10-
<version>3.4.3-SNAPSHOT</version>
10+
<version>3.5.0</version>
1111
</parent>
1212

1313
<artifactId>tcases-cli</artifactId>

tcases-io/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.cornutum.tcases</groupId>
99
<artifactId>tcases</artifactId>
10-
<version>3.4.3-SNAPSHOT</version>
10+
<version>3.5.0</version>
1111
</parent>
1212

1313
<artifactId>tcases-io</artifactId>

tcases-lib/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.cornutum.tcases</groupId>
99
<artifactId>tcases</artifactId>
10-
<version>3.4.3-SNAPSHOT</version>
10+
<version>3.5.0</version>
1111
</parent>
1212

1313
<artifactId>tcases-lib</artifactId>

tcases-maven-plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.cornutum.tcases</groupId>
99
<artifactId>tcases</artifactId>
10-
<version>3.4.3-SNAPSHOT</version>
10+
<version>3.5.0</version>
1111
</parent>
1212

1313
<artifactId>tcases-maven-plugin</artifactId>

tcases-moco/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.cornutum.tcases</groupId>
99
<artifactId>tcases</artifactId>
10-
<version>3.4.3-SNAPSHOT</version>
10+
<version>3.5.0</version>
1111
</parent>
1212

1313
<artifactId>tcases-moco</artifactId>

tcases-openapi/README.md

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- [Then use Tcases to generate your API test cases ](#then-use-tcases-to-generate-your-api-test-cases)
77
- [How do you run generated API test cases?](#how-do-you-run-generated-api-test-cases)
88
- [Why Tcases for OpenAPI? ](#why-tcases-for-openapi)
9+
- [How does it work? ](#how-does-it-work)
910
- [Is your OpenAPI spec an input model? No, it's two! ](#is-your-openapi-spec-an-input-model-no-its-two)
1011
- [Running Tcases for OpenAPI from the command line ](#running-tcases-for-openapi-from-the-command-line)
1112
- [Running Tcases for OpenAPI using Maven](#running-tcases-for-openapi-using-maven)
@@ -211,6 +212,29 @@ clients. But Tcases for OpenAPI makes no such assumptions. It relentlessly cover
211212
actually defines. If you find that some of these test cases are surprising, you may find an opportunity to make your
212213
OpenAPI spec even better.
213214

215+
## How does it work? ##
216+
217+
Your OpenAPI spec defines rules for all the data that flows to and from the API server. Most of these rules are represented by
218+
the [schema](http://spec.openapis.org/oas/v3.0.2#schema-object) that describe each data item. By default, Tcases for OpenAPI
219+
uses these schema definitions to compose a model of the input space of your API -- a model of all the forms of data that
220+
could be accepted. From this input model, Tcases can generate a set of test cases, including not only cases of valid data but also
221+
cases of data that do not match the schema and are expected to produce an error response.
222+
223+
Alternatively, Tcases for OpenAPI can create an input model from a different source: the <A name="examples">examples</A>
224+
defined in your OpenAPI spec. Every request parameter, content object, or schema can list at least one example data
225+
item. From these, Tcases for OpenAPI can assemble a different set of test cases, using only example data. Examples are
226+
presumed to be valid data, so no failure cases are generated from this input model. To generate test cases from example
227+
data, you must provide at least one example for every data item, although that might be [easier than you
228+
think](#example-tips).
229+
230+
So which source should you use for your test cases? Schemas or examples? The answer, of course, is both. Each source has
231+
complementary advantages and disadvantages. With example data, you can make sure that your tests cover specific "happy
232+
path" cases. However, creating these examples, which are not strictly required, is extra work and the resulting test
233+
cases produce minimal coverage at best. On the other hand, by generating test cases from the schemas, you can get
234+
complete coverage of both valid and error cases automatically, although the generated test inputs are synthetic and not
235+
completely realistic.
236+
237+
214238
## Is your OpenAPI spec an input model? No, it's two! ##
215239

216240
There are two sides to your API: the requests and their responses. Both are defined in an OpenAPI spec. But which side
@@ -260,6 +284,13 @@ tcases-api -C -f someTests.json -o otherDir my-api.json
260284
tcases-api -S -c fail < my-api.json
261285
```
262286

287+
288+
```bash
289+
# Generate tests for requests, using example data defined in 'my-api.json'. Write results to 'my-api-Request-Tests.json'.
290+
# (See 'OpenAPI tips, For example test cases'.)
291+
tcases-api -X my-api.json
292+
```
293+
263294
## Running Tcases for OpenAPI using Maven ##
264295

265296
You can also run Tcases for OpenAPI with the [Tcases Maven Plugin](http://www.cornutum.org/tcases/docs/tcases-maven-plugin/),
@@ -295,7 +326,6 @@ Some examples:
295326
# Generate tests for requests and responses defined by all OpenAPI specs of the
296327
# form ${basedir}/src/test/tcases/openapi/**/my-api.(json,yaml). Write results to
297328
# ${basedir}/target/tcases/openapi.
298-
299329
mvn tcases:api -Dproject=my-api
300330
```
301331

@@ -304,10 +334,15 @@ mvn tcases:api -Dproject=my-api
304334
# Generate an HTML report of tests for requests and responses for each
305335
# OpenAPI spec found in ${basedir}/src/test/tcases/openapi. Report a failure if
306336
# any input modelling condition is found.
307-
308337
mvn tcases:api -Dhtml=true -DonModellingCondition=fail
309338
```
310339

340+
```bash
341+
# 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+
311346

312347
## Semantic linting with Tcases for OpenAPI ##
313348

@@ -418,6 +453,37 @@ To use Tcases for OpenAPI effectively, there are some things to keep in mind whe
418453
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
419454
different types of values are actually expected, you can define this explicitly using the `oneOf` keyword.
420455
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+
421487
## Test case generation tips ##
422488
423489
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

Comments
 (0)