-
Notifications
You must be signed in to change notification settings - Fork 27
W-14237985 mtf #232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sathya0
wants to merge
53
commits into
v1.1
Choose a base branch
from
W-14237985-mtf-docs-publication-sg
base: v1.1
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
W-14237985 mtf #232
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
e014104
interim
sathya0 c6ef92a
fix
sathya0 fb12bc6
more
sathya0 ebbc499
Update mtf.adoc
sathya0 ad05148
Update mtf.adoc
sathya0 dabfc1f
Update mtf.adoc
sathya0 ce86bce
more
sathya0 299b056
more
sathya0 7907038
more
sathya0 ededa50
Update testing-writing-your-first-test-case.adoc
sathya0 5e2e5eb
Update testing-writing-your-first-munit-test.adoc
sathya0 b8fee75
Update nav.adoc
sathya0 a88ef09
more
sathya0 6ebeaa0
more
sathya0 6bc9f28
fixes
sathya0 49480e2
Update mtf-testing-sources.adoc
sathya0 c3ab565
Update mtf-expecting-errors.adoc
sathya0 f6c40d5
editorial
sathya0 24f26bf
fixes
sathya0 029ec3e
Update mtf-expecting-errors.adoc
sathya0 3f0d9ae
more
sathya0 a5e54a6
more
sathya0 7ce9499
Update mtf-metadata-testing.adoc
sathya0 efabf73
more
sathya0 85e6117
Update mtf-metadata-testing.adoc
sathya0 cbb5078
Update modules/ROOT/pages/mtf-testing-sources.adoc
sathya0 b859662
Update mtf-parameterized-tests.adoc
sathya0 5698100
more
sathya0 92e1227
more
sathya0 05553d2
Update connectivity-testing.adoc
sathya0 e7e84bf
Update munit-extensions-maven-plugin-configuration.adoc
sathya0 de3c1fc
Update munit-extensions-maven-plugin-configuration.adoc
sathya0 6d8e8fc
editorial
sathya0 21a3ef3
more
sathya0 698847b
more
sathya0 fea1b2c
Update munit-extensions-maven-plugin-configuration.adoc
sathya0 ca93926
editorial
sathya0 d2b9c67
Update modules/ROOT/pages/mtf-using-test-classes.adoc
sathya0 03337ff
Update modules/ROOT/pages/mtf-using-test-classes.adoc
sathya0 4a7a44b
Update munit-extensions-maven-plugin-configuration.adoc
sathya0 da0fb21
Update munit-extensions-maven-plugin-configuration.adoc
sathya0 e66d9ac
Update munit-extensions-maven-plugin-configuration.adoc
sathya0 4444b22
Update munit-extensions-maven-plugin-configuration.adoc
sathya0 41f9248
Update munit-extensions-maven-plugin.adoc
sathya0 a8516ad
Update munit-extensions-maven-plugin-configuration.adoc
sathya0 fae173f
editorial
sathya0 88bb4e2
Update testing-writing-your-first-munit-test.adoc
sathya0 719a3e6
Update testing-writing-your-first-munit-test.adoc
sathya0 7b093eb
editorial
sathya0 8a42181
editorial
sathya0 2cbe5d0
Update munit-extensions-maven-plugin.adoc
sathya0 bcc2b1e
Update munit-extensions-maven-plugin.adoc
sathya0 f0442df
tech review
sathya0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| = Connectivity | ||
| ifndef::env-site,env-github[] | ||
| include::_attributes.adoc[] | ||
| endif::[] | ||
|
|
||
| Test the connectivity defined for your module. | ||
|
|
||
| == Before You Begin | ||
|
|
||
| * Understand how to define a connection for your module. For more information, refer to xref:connections.adoc[]. | ||
| * Add the `mtf-tools` dependency to your project: | ||
| + | ||
| [source,xml,linenums] | ||
| ---- | ||
| <dependency> | ||
| <groupId>com.mulesoft.munit</groupId> | ||
| <artifactId>mtf-tools</artifactId> | ||
| <version>1.2.0</version> | ||
| <classifier>mule-plugin</classifier> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| ---- | ||
|
|
||
| == Test Connectivity | ||
|
|
||
| The `test-connectivity` processor establishes a connection using the given configuration. If testing connectivity with the given configuration fails, the processor fails with the proper exception, description, and error type (if present). | ||
|
|
||
| === Successful Connection | ||
|
|
||
| When you test that a connection is valid, you are validating that the processor does not fail. A successful connection test appears as follows: | ||
|
|
||
| [source,xml,linenums] | ||
| ---- | ||
| <munit:test name="validConnectionTest"> | ||
| <munit:execution> | ||
| <mtf:test-connectivity config-ref="validConnection"/> | ||
| </munit:execution> | ||
| </munit:test> | ||
| ---- | ||
|
|
||
| === Invalid Connection | ||
|
|
||
| When a connection fails, the processor fails. Therefore, to test an invalid connection, include an expected exception and expected error description in the test: | ||
|
|
||
| [source,xml,linenums] | ||
| ---- | ||
| <munit:test name="invalidConnectionTest" | ||
| expectedException="com.example.MyConnectionException" | ||
| expectedErrorDescription="An error occurred while connecting"> | ||
| <munit:execution> | ||
| <mtf:test-connectivity config-ref="invalidConnection"/> | ||
| </munit:execution> | ||
| </munit:test> | ||
| ---- | ||
|
|
||
| If the connection fails with an error type, you can include an expected error type as well: | ||
|
|
||
| [source,xml,linenums] | ||
| ---- | ||
| <munit:test name="invalidConnectionWithErrorTypeTest" | ||
| expectedException="com.example.MyConnectionException" | ||
| expectedErrorType="EXAMPLE:INVALID_CREDENTIALS" | ||
| expectedErrorDescription="An error occurred while connecting"> | ||
| <munit:execution> | ||
| <mtf:test-connectivity config-ref="invalidConnectionWithErrorType"/> | ||
| </munit:execution> | ||
| </munit:test> | ||
| ---- | ||
|
|
||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| = Expected Errors | ||
sathya0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ifndef::env-site,env-github[] | ||
| include::_attributes.adoc[] | ||
| endif::[] | ||
|
|
||
| Validate the error types and error descriptions that your module throws. | ||
sathya0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| == Before You Begin | ||
|
|
||
| You must know how to define the errors that your module throws. For more information, refer to xref:errors.adoc[]. | ||
|
|
||
| == Example: Error Definition | ||
|
|
||
| In this example, the module defines errors as follows: | ||
|
|
||
| .Error type definition | ||
| [source,java,linenums] | ||
| ---- | ||
| public enum SimpleError implements ErrorTypeDefinition<SimpleError> { | ||
| INVALID_PARAMETER, TIME_OUT, NOT_ALLOWED | ||
| } | ||
| ---- | ||
|
|
||
| .Error type provider | ||
| [source,java,linenums] | ||
| ---- | ||
| public class ExecuteErrorsProvider implements ErrorTypeProvider { | ||
| @Override | ||
| public Set<ErrorTypeDefinition> getErrorTypes() { | ||
| HashSet<ErrorTypeDefinition> errors = new HashSet<>(); | ||
| errors.add(SimpleError.INVALID_PARAMETER); | ||
| errors.add(SimpleError.TIME_OUT); | ||
| return errors; | ||
| } | ||
| } | ||
| ---- | ||
|
|
||
| .Operation that throws the error | ||
| [source,java,linenums] | ||
| ---- | ||
| @Throws(ExecuteErrorsProvider.class) | ||
| public void execute(Integer number) { | ||
| if (number <= 0) { | ||
| throw new ModuleException("Parameter 'number' should be greater than 0", SimpleError.INVALID_PARAMETER); | ||
| } | ||
| } | ||
| ---- | ||
|
|
||
| Use MTF to create tests to validate the expected error type and error description. | ||
|
|
||
| == Validate an Expected Error Type | ||
|
|
||
| To validate that the error thrown by the module in the example has the proper error type: | ||
|
|
||
| [source, xml, linenums] | ||
| ---- | ||
| <munit:test name="testErrorType" expectedErrorType="TEST-CONNECTOR:INVALID_PARAMETER"> | ||
| <munit:execution> | ||
| <test-connector:execute number="0"/> | ||
| </munit:execution> | ||
| </munit:test> | ||
| ---- | ||
|
|
||
| == Validate an Expected Error Description | ||
|
|
||
| To validate that the error thrown by the module in the example has the proper error description: | ||
|
|
||
| [source, xml, linenums] | ||
| ---- | ||
| <munit:test name="testErrorDescription" expectedErrorDescription="Parameter 'number' should be greater than 0"> | ||
| <munit:execution> | ||
| <test-connector:execute number="0"/> | ||
| </munit:execution> | ||
| </munit:test> | ||
| ---- | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.