Skip to content

Commit

Permalink
NOJIRA: Improving documentation for Kettle Testing Framework
Browse files Browse the repository at this point in the history
Clarification for 'expect' field and explanation for how to run multiple tests together
  • Loading branch information
kunal-mohta committed Jul 13, 2018
1 parent 738e44b commit 4a160f6
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions docs/KettleTestingFramework.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ You can run a live version of this sample by running
from the [examples/testingSimpleConfig](../examples/testingSimpleConfig) directory of this project.

This sample sets up JSON configuration to load the `examples.simpleConfig` application from this module's `examples` directory, and then
defines a single request test component, named `getRequest`, of type `kettle.test.request.http` which targets its path. The `sequence` section
defines a single request test component, named `getRequest`, of type `kettle.test.request.http` which targets its path. It also sets the expected number of successful assertions by specifying `expect: 2`. The `sequence` section
of the configuration then consists of two elements – the first sends the request, and the second listens for the `onComplete` event fired by
the request and verifies that the returned payload is exactly as expected.

Note the use of two particular pieces of Kettle's infrastructure – firstly the use of module-relative paths, where we use the contextualised
reference `%kettle` in order to resolve a file path relative to the base directory of this module, and secondly the Kettle testing assert function
[`kettle.test.assertJSONResponse`](#helper-methods-for-making-assertions-on-oncomplete), which is a helpful all-in-one utility for verifying an HTTP response status code as well as response payload.
[`kettle.test.assertJSONResponse`](#helper-methods-for-making-assertions-on-oncomplete), which is a helpful all-in-one utility for verifying an HTTP response status code as well as response payload. Note that `kettle.test.assertJSONResponse` actually runs two jqUnit assert functions, one on the response status code, and another on the response being JSON (hence the `expect: 2`)

<a id="#kettle.test.request.http"></a>

Expand Down Expand Up @@ -442,6 +442,32 @@ Analogous with `kettle.test.request.httpCookie`, there is a session-aware varian
with that of `kettle.test.request.httpCookie`, in particular being able to share access to the same `kettle.test.cookieJar` component to enable a mixed series of HTTP and WebSockets requests
to be contextualised by the same session cookies.

## Running multiple tests together
Simply include all the test files in a single file using `require` and run that file.\
For example,
```
"use strict";
var fluid = require("infusion");
var kettle = require("kettle");
kettle.loadTestingSupport();
// array of paths to all tests (relative to the file containing this code) we want to run together
var testIncludes = [
"path/to/test/one",
"path/to/test/two",
.
.
.
];
fluid.each(testIncludes, function (path) {
require(path);
});
```
For reference, you can see Kettle's own such file [here](https://github.com/fluid-project/kettle/blob/master/tests/all-tests.js)

## Framework tests

Please consult the [test cases](../tests) for the framework for more examples of Kettle primitives as well as the Kettle testing framework in action.

0 comments on commit 4a160f6

Please sign in to comment.