Skip to content
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

W-14237985 mtf #232

Open
wants to merge 53 commits into
base: v1.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
e014104
interim
sathya0 Oct 9, 2023
c6ef92a
fix
sathya0 Oct 19, 2023
fb12bc6
more
sathya0 Oct 19, 2023
ebbc499
Update mtf.adoc
sathya0 Oct 19, 2023
ad05148
Update mtf.adoc
sathya0 Oct 19, 2023
dabfc1f
Update mtf.adoc
sathya0 Oct 19, 2023
ce86bce
more
sathya0 Oct 19, 2023
299b056
more
sathya0 Oct 19, 2023
7907038
more
sathya0 Oct 19, 2023
ededa50
Update testing-writing-your-first-test-case.adoc
sathya0 Oct 19, 2023
5e2e5eb
Update testing-writing-your-first-munit-test.adoc
sathya0 Oct 19, 2023
b8fee75
Update nav.adoc
sathya0 Oct 19, 2023
a88ef09
more
sathya0 Oct 20, 2023
6ebeaa0
more
sathya0 Oct 20, 2023
6bc9f28
fixes
sathya0 Oct 23, 2023
49480e2
Update mtf-testing-sources.adoc
sathya0 Oct 23, 2023
c3ab565
Update mtf-expecting-errors.adoc
sathya0 Oct 23, 2023
f6c40d5
editorial
sathya0 Oct 24, 2023
24f26bf
fixes
sathya0 Oct 26, 2023
029ec3e
Update mtf-expecting-errors.adoc
sathya0 Oct 26, 2023
3f0d9ae
more
sathya0 Oct 26, 2023
a5e54a6
more
sathya0 Oct 26, 2023
7ce9499
Update mtf-metadata-testing.adoc
sathya0 Oct 26, 2023
efabf73
more
sathya0 Oct 26, 2023
85e6117
Update mtf-metadata-testing.adoc
sathya0 Oct 26, 2023
cbb5078
Update modules/ROOT/pages/mtf-testing-sources.adoc
sathya0 Oct 27, 2023
b859662
Update mtf-parameterized-tests.adoc
sathya0 Oct 30, 2023
5698100
more
sathya0 Oct 30, 2023
92e1227
more
sathya0 Oct 30, 2023
05553d2
Update connectivity-testing.adoc
sathya0 Oct 30, 2023
e7e84bf
Update munit-extensions-maven-plugin-configuration.adoc
sathya0 Nov 2, 2023
de3c1fc
Update munit-extensions-maven-plugin-configuration.adoc
sathya0 Nov 2, 2023
6d8e8fc
editorial
sathya0 Nov 9, 2023
21a3ef3
more
sathya0 Nov 9, 2023
698847b
more
sathya0 Nov 9, 2023
fea1b2c
Update munit-extensions-maven-plugin-configuration.adoc
sathya0 Nov 9, 2023
ca93926
editorial
sathya0 Nov 10, 2023
d2b9c67
Update modules/ROOT/pages/mtf-using-test-classes.adoc
sathya0 Nov 10, 2023
03337ff
Update modules/ROOT/pages/mtf-using-test-classes.adoc
sathya0 Nov 10, 2023
4a7a44b
Update munit-extensions-maven-plugin-configuration.adoc
sathya0 Nov 13, 2023
da0fb21
Update munit-extensions-maven-plugin-configuration.adoc
sathya0 Nov 14, 2023
e66d9ac
Update munit-extensions-maven-plugin-configuration.adoc
sathya0 Nov 14, 2023
4444b22
Update munit-extensions-maven-plugin-configuration.adoc
sathya0 Nov 14, 2023
41f9248
Update munit-extensions-maven-plugin.adoc
sathya0 Nov 14, 2023
a8516ad
Update munit-extensions-maven-plugin-configuration.adoc
sathya0 Nov 14, 2023
fae173f
editorial
sathya0 Nov 15, 2023
88bb4e2
Update testing-writing-your-first-munit-test.adoc
sathya0 Nov 17, 2023
719a3e6
Update testing-writing-your-first-munit-test.adoc
sathya0 Nov 17, 2023
7b093eb
editorial
sathya0 Nov 27, 2023
8a42181
editorial
sathya0 Nov 29, 2023
2cbe5d0
Update munit-extensions-maven-plugin.adoc
sathya0 Nov 29, 2023
bcc2b1e
Update munit-extensions-maven-plugin.adoc
sathya0 Nov 29, 2023
f0442df
tech review
sathya0 Dec 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,24 @@
*** xref:sample-data.adoc[Sample Data]
*** xref:security-best-practices.adoc[Security]
*** xref:threading-asynchronous-processing.adoc[Threading and Asynchronous Processing]
** xref:testing.adoc[Testing your Module]
*** xref:testing-writing-your-first-test-case.adoc[Writing Your First Test Case]
** xref:about-connector-certification-program-guidelines.adoc[About MuleSoft Connector Certification Program Guidelines]
*** xref:certification-guidelines-for-connectors.adoc[Technical Guidelines for Connector Certifications]
** xref:troubleshooting.adoc[Troubleshooting]
** xref:license.adoc[Licensing]
** xref:validators.adoc[Validators with Mule SDK]
** xref:dmt.adoc[DevKit to SDK Migration Tool]
* xref:xml-sdk.adoc[XML SDK]
* xref:testing.adoc[Testing Your Module]
** xref:mtf.adoc[Module Testing Framework (MTF)]
*** xref:testing-writing-your-first-munit-test.adoc[Creating Your Test]
*** xref:mtf-testing-examples.adoc[MTF Test Examples]
**** xref:mtf-testing-sources.adoc[Sources]
**** xref:mtf-expecting-errors.adoc[Expected Errors]
**** xref:mtf-parameterized-tests.adoc[Parameterization]
**** xref:mtf-using-test-classes.adoc[Classes]
**** xref:testing-oauth-modules.adoc[OAuth-Enabled Modules]
**** xref:mtf-metadata-testing.adoc[Metadata]
**** xref:connectivity-testing.adoc[Connectivity]
*** xref:munit-extensions-maven-plugin-configuration.adoc[Configuring the MUnit Extensions Maven Plugin]
*** xref:munit-extensions-maven-plugin.adoc[Operating the MUnit Extensions Maven Plugin]
** xref:testing-writing-your-first-test-case.adoc[FlowRunner (Deprecated)]
73 changes: 73 additions & 0 deletions modules/ROOT/pages/connectivity-testing.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
= Connectivity
ifndef::env-site,env-github[]
include::_attributes.adoc[]
endif::[]

Test the connectivity defined for your module.

== Before You Begin

* Know how to define a connection for your module. For more information, refer to xref:connections.adoc[].
sathya0 marked this conversation as resolved.
Show resolved Hide resolved
* To create connectivity tests, add the `mtf-tools` dependency to your project:
sathya0 marked this conversation as resolved.
Show resolved Hide resolved
+
[source,xml,linenums]
----
<dependency>
<groupId>com.mulesoft.munit</groupId>
<artifactId>mtf-tools</artifactId>
<version>1.0.0</version>
<classifier>mule-plugin</classifier>
<scope>test</scope>
</dependency>
----

CAUTION: Connectivity testing is available since Mule runtime engine 4.2.0. If your module has a minimum Mule version earlier than 4.2.0, add `minMuleVersion` to your connectivity testing suite, for example: `<munit:config name="connectivity-testing-suite" minMuleVersion="4.2.0"/>`.
sathya0 marked this conversation as resolved.
Show resolved Hide resolved

== 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 looks as follows:
sathya0 marked this conversation as resolved.
Show resolved Hide resolved

[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>
----


sathya0 marked this conversation as resolved.
Show resolved Hide resolved

75 changes: 75 additions & 0 deletions modules/ROOT/pages/mtf-expecting-errors.adoc
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>
----
Loading