Skip to content

Commit

Permalink
Release 3.6.0 (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
kerrykimbrough authored May 21, 2021
1 parent f20b0fd commit 503d16e
Show file tree
Hide file tree
Showing 17 changed files with 69 additions and 24 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

## What's New? ##

* The latest version ([Tcases 3.5.1](ReleaseNotes.md#351)) is now available at the Maven Central Repository.
* The latest version ([Tcases 3.6.0](ReleaseNotes.md#360)) is now available at the Maven Central Repository.
See [*How To Download Tcases*](HowToDownload.md) for download instructions.

* Tcases 3.5.1 provides improvements to Tcases for OpenAPI. See the [release notes](ReleaseNotes.md#351) for details.
* Tcases 3.6.0 provides improvements to Tcases for OpenAPI. See the [release notes](ReleaseNotes.md#360) for details.

* Having trouble with Tcases? Check out [these tips](./Troubleshooting-FAQs.md).

Expand Down
21 changes: 21 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Release Notes #

## 3.6.0 ##

This release adds new options for Tcases for OpenAPI to improve the quality of generated executable tests.

* **Test method timeout** [[171](https://github.com/Cornutum/tcases/issues/171)]

Each test method submits a single API request, but it's possible for a faulty request to run forever. To handle this
situation, you can specify a timeout that defines the maximum time (in milliseconds) to complete an individual test
method. If a method continues past this time limit, a test failure occurs. When running `tcases-api-test` from the command
line, use the `-u` option (for details, run `tcases-api-test -help`). When using Maven to run `tcases:api-test`, use
the `timeout` option (for details, run `mvn tcases:help -Dgoal=api-test -Ddetail=true`).

* **Generate a separate test file for each API resource path** [[168](https://github.com/Cornutum/tcases/issues/168)]

By default, Tcases for OpenAPI creates a single test source file that contains the test cases generated for all resource
paths defined by the OpenAPI spec. But that can be unwieldy for an extensive API that defines a large number of
endpoints. To better deal with this situation, you have the option to generate multiple test source files, each containing
the test cases for a single API resource path. When running `tcases-api-test` from the command
line, use the `-S` option (for details, run `tcases-api-test -help`). When using Maven to run `tcases:api-test`, use
the `byPath` option (for details, run `mvn tcases:help -Dgoal=api-test -Ddetail=true`).

## 3.5.1 ##

This release provides improvements to Tcases for OpenAPI when generating API tests using the
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>org.cornutum.tcases</groupId>
<artifactId>tcases</artifactId>
<packaging>pom</packaging>
<version>3.5.2-SNAPSHOT</version>
<version>3.6.0</version>

<name>Tcases</name>
<description>Generates test cases from system input space models</description>
Expand Down
2 changes: 1 addition & 1 deletion tcases-ant/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.cornutum.tcases</groupId>
<artifactId>tcases</artifactId>
<version>3.5.2-SNAPSHOT</version>
<version>3.6.0</version>
</parent>

<artifactId>tcases-ant</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion tcases-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.cornutum.tcases</groupId>
<artifactId>tcases</artifactId>
<version>3.5.2-SNAPSHOT</version>
<version>3.6.0</version>
</parent>

<artifactId>tcases-cli</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,7 @@ public static void run( Options options) throws Exception
testTarget.setDir( apiSpecFile.getParentFile());
}

logger_.info( "Writing API test using {} and {}", testWriter, testCaseWriter);
logger_.info( "Writing API tests using {} and {}", testWriter, testCaseWriter);
if( options.isByPath())
{
String testBaseName = getTestName( testWriter, testSource, testTarget);
Expand Down
2 changes: 1 addition & 1 deletion tcases-io/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.cornutum.tcases</groupId>
<artifactId>tcases</artifactId>
<version>3.5.2-SNAPSHOT</version>
<version>3.6.0</version>
</parent>

<artifactId>tcases-io</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion tcases-lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.cornutum.tcases</groupId>
<artifactId>tcases</artifactId>
<version>3.5.2-SNAPSHOT</version>
<version>3.6.0</version>
</parent>

<artifactId>tcases-lib</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion tcases-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.cornutum.tcases</groupId>
<artifactId>tcases</artifactId>
<version>3.5.2-SNAPSHOT</version>
<version>3.6.0</version>
</parent>

<artifactId>tcases-maven-plugin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion tcases-moco/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.cornutum.tcases</groupId>
<artifactId>tcases</artifactId>
<version>3.5.2-SNAPSHOT</version>
<version>3.6.0</version>
</parent>

<artifactId>tcases-moco</artifactId>
Expand Down
36 changes: 30 additions & 6 deletions tcases-openapi/Running-Api-Test-Cases.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- [How does it work?](#how-does-it-work)
- [Example: REST Assured and JUnit](#example-rest-assured-and-junit)
- [Example: Create a specific TestNG class](#example-create-a-specific-testng-class)
- [Example: Organize tests by API resource path](#example-organize-tests-by-api-resource-path)
- [Example: Create tests from examples](#example-create-tests-from-examples)
- [Understanding the TestWriter API](#understanding-the-testwriter-api)
- [Generating request inputs](#generating-request-inputs)
Expand Down Expand Up @@ -103,8 +104,8 @@ You can see a summary of the generation process in the `tcases-api-test.log` fil
12:48:36.181 INFO o.c.t.generator.TupleGenerator - FunctionInputDef[GET_pets]: Created 6 failure test cases
12:48:36.187 INFO o.c.t.generator.TupleGenerator - FunctionInputDef[GET_pets]: Completed 11 test cases
...
12:48:36.443 INFO o.c.t.openapi.ApiTestCommand - Writing API test using JUnitTestWriter[] and RestAssuredTestCaseWriter[]
12:48:36.444 INFO o.c.t.openapi.ApiTestCommand - Writing API test to src/test/java/org/examples/SwaggerPetstoreTest.java
12:48:36.443 INFO o.c.t.openapi.ApiTestCommand - Writing API tests using JUnitTestWriter[] and RestAssuredTestCaseWriter[]
12:48:36.444 INFO o.c.t.openapi.ApiTestCommand - Writing all API tests to src/test/java/org/examples/SwaggerPetstoreTest.java
```

And you can see the generated source code in `SwaggerPetstoreTest.java`:
Expand Down Expand Up @@ -155,8 +156,8 @@ You can see the difference in the `tcases-api-test.log` file:
14:20:18.574 INFO o.c.t.openapi.ApiTestCommand - Reading API spec from ./petstore-expanded.yaml
14:20:18.905 INFO o.c.t.openapi.ApiTestCommand - Generating request test cases using random seed=345589
...
14:20:19.222 INFO o.c.t.openapi.ApiTestCommand - Writing API test using TestNgTestWriter[] and RestAssuredTestCaseWriter[]
14:20:19.222 INFO o.c.t.openapi.ApiTestCommand - Writing API test to ./MyTests.java
14:20:19.222 INFO o.c.t.openapi.ApiTestCommand - Writing API tests using TestNgTestWriter[] and RestAssuredTestCaseWriter[]
14:20:19.222 INFO o.c.t.openapi.ApiTestCommand - Writing all API tests to ./MyTests.java
```

And also in the the generated source code in `MyTests.java`:
Expand Down Expand Up @@ -186,6 +187,29 @@ public class MyTests extends MyBaseClass {
}
```

### Example: Organize tests by API resource path ###

By default, Tcases for OpenAPI creates a single test source file that contains the test cases generated for all
resource paths defined by the OpenAPI spec. But that can be unwieldy for an extensive API that defines a large
number of endpoints. To better deal with this situation, you have the option to generate multiple test source files,
each containing the test cases for a single API resource path.

```bash
# Generate JUnit tests for requests defined by the examples in 'petstore-expanded.yaml'.
# Write test cases for each API path to a separate test source file
tcases-api-test -S -n org.examples.Petstore petstore-expanded.yaml
```

You can see a summary of the result in the `tcases-api-test.log` file:

```
16:51:05.341 INFO o.c.t.openapi.ApiTestCommand - M.N.P (YYYY-MM-DD)
16:51:05.346 INFO o.c.t.openapi.ApiTestCommand - Reading API spec from ./petstore-expanded.yaml
...
16:51:05.955 INFO o.c.t.openapi.ApiTestCommand - Writing API test using JUnitTestWriter[] and RestAssuredTestCaseWriter[]
16:51:05.956 INFO o.c.t.openapi.ApiTestCommand - Writing API tests for /pets to ./Petstore_PetsTest.java
16:51:06.005 INFO o.c.t.openapi.ApiTestCommand - Writing API tests for /pets/{id} to ./Petstore_PetsIdTest.java
```
### Example: Create tests from examples ###

By default, Tcases for OpenAPI generates test cases using the schemas defined by the OpenAPI spec.
Expand All @@ -204,8 +228,8 @@ You can see a summary of the result in the `tcases-api-test.log` file:
12:48:35.773 INFO o.c.t.openapi.ApiTestCommand - Reading API spec from ./petstore-expanded.yaml
12:48:36.114 INFO o.c.t.openapi.ApiTestCommand - Generating request test cases using API examples
...
12:48:36.443 INFO o.c.t.openapi.ApiTestCommand - Writing API test using JUnitTestWriter[] and RestAssuredTestCaseWriter[]
12:48:36.444 INFO o.c.t.openapi.ApiTestCommand - Writing API test to ./PetstoreExamplesTest.java
12:48:36.443 INFO o.c.t.openapi.ApiTestCommand - Writing API tests using JUnitTestWriter[] and RestAssuredTestCaseWriter[]
12:48:36.444 INFO o.c.t.openapi.ApiTestCommand - Writing all API tests to ./PetstoreExamplesTest.java
```

### Understanding the TestWriter API ###
Expand Down
2 changes: 1 addition & 1 deletion tcases-openapi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.cornutum.tcases</groupId>
<artifactId>tcases</artifactId>
<version>3.5.2-SNAPSHOT</version>
<version>3.6.0</version>
</parent>

<artifactId>tcases-openapi</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2077,9 +2077,9 @@ private Schema<?> derivedExampleSchemaFor( Schema<?> instanceSchema, String inst
exampleSchema =
new ComposedSchema()
.oneOf(
( IntStream.range( 0, members.size())
.mapToObj( i -> resultFor( String.format( "%s[%s]", oneOf? "oneOf" : "anyOf", i), () -> exampleSchemaFor( members.get(i))))
.collect( toList())));
IntStream.range( 0, members.size())
.mapToObj( i -> resultFor( String.format( "%s[%s]", oneOf? "oneOf" : "anyOf", i), () -> exampleSchemaFor( members.get(i))))
.collect( toList()));
}

else if( "array".equals( instanceType))
Expand Down
2 changes: 1 addition & 1 deletion tcases-rest-assured/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.cornutum.tcases</groupId>
<artifactId>tcases</artifactId>
<version>3.5.2-SNAPSHOT</version>
<version>3.6.0</version>
</parent>

<artifactId>tcases-rest-assured</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion tcases-shell/docs/Tcases-Guide.htm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<IMG src="cornutum-logo.png"/>
<SPAN class="title"> Tcases: The Complete Guide </SPAN> <BR/>
<SPAN class="subtitle">Version ${shell.version} (${shell.timestamp})</SPAN><BR/>
<SPAN class="subtitle">&copy; 2012-2020 Cornutum Project</SPAN>
<SPAN class="subtitle">&copy; 2012-2021 Cornutum Project</SPAN>
</DIV>

<H2>Contents</H2>
Expand Down
2 changes: 1 addition & 1 deletion tcases-shell/docs/Tcases-Json.htm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<IMG src="cornutum-logo.png"/>
<SPAN class="title"> Tcases: The JSON Guide </SPAN> <BR/>
<SPAN class="subtitle">Version ${shell.version} (${shell.timestamp})</SPAN><BR/>
<SPAN class="subtitle">&copy; 2012-2020 Cornutum Project</SPAN>
<SPAN class="subtitle">&copy; 2012-2021 Cornutum Project</SPAN>
</DIV>

<H2>Contents</H2>
Expand Down
2 changes: 1 addition & 1 deletion tcases-shell/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.cornutum.tcases</groupId>
<artifactId>tcases</artifactId>
<version>3.5.2-SNAPSHOT</version>
<version>3.6.0</version>
</parent>

<artifactId>tcases-shell</artifactId>
Expand Down

0 comments on commit 503d16e

Please sign in to comment.