Project Details

Rules and Conditional Execution

ConditionalExecutionRule

Based on a jUnit rule, it relates to the annotations present on the code. The ConnectorsTestCase abstract class declares a @ClassRule of this type, and also every subclass declares a @Rule. The ClassRules execute before each class is run, and common Rules execute before each method invokes.

This gracefully skips tests and test classes, by adding an annotation @ConditionalExecutionRule and the conditions it must verify and deny. For example, these testsl run only if the connector has no metadata and doesn’t use OAuth authentication:

@ConditionalExecutionRule( verify = { HasNoMetadata.class },
				      deny = { UsesOAuthConfiguration.class })
	@Test
	public void myConditionalTest(){
	...
}

Rules Conditions

Rule conditions are the classes fed to the conditional executions annotation. The conditions encapsulate the logic around its title.

For example, instead of skipping a test by saying:
assumeThat(!processor.getRequiredAttributes().isEmpty());

Create a condition that implements RuleCondition encapsulating the logic. Then, we can annotate the tests with a ConditionalExecution annotation, with the same result than before:
@ConditionalExecutionRule( verify = { ProcessorHasRequiredFields.class }}

Test Suites

ConnectorTestSuite

Use with the jUnit suite class, grouping together the TestClasses to be run with the data from a single connector. Declare which connector to test by passing the routes to its testdata files.

It’s important to add all available test classes (below), since this suite is the same for every connector. The next section shows how tests that are not applicable are skipped based on the connectors properties.

Test Cases

The test cases covered so far include ConnectivityTesting, DamapperCompliance, and XmlGeneration, as described in the Connectors QA Guideline. Each of these classes inherit from ConnectorTestCases, which provides utility methods and scaffolding that simplifies test writing.

In every class we have a me thod annotated with @Parameters, that injects the parameterized data one element at a time for the suite to run.

For example, the tests in DatamapperTestCases class run once for each
processor present in the connector. This can be seen in the method dataProvider, that returns a collection with pairs of (processorName, processorInstance), which are exactly the pair of values its constructor receives.

ConnectivityTestCases

  • -testConnectivity_InvalidCredentials: Populates the configuration with invalid credentials, running the connectivity test once for each field. Every run has only one invalid value.

  • -testConnectivity_NoneRequiredSet: Leaves all the required fields of the configuration empty

  • -testConnectivity_ValidCredentials: Populates the configuration with valid credentials in all the required fields.

  • -testConnectivityButtonIsAvailable: Verifies the "Test Connectivity" button is visible in the config dialog

  • -testPasswordFieldHasHiddenText: Verifies the password field does not show the input in plain text

DatamapperTestCases

Precondition: The configuration and operation are populated with valid data in all the required fields.

  • -testEmptyMetadataRetrieved():Runs only if the connector doesn’t have static nor dynamic metadata. Verifies neither input nor output types are retrieved with datamapper.

  • -testOverrideMetadata_Input(): As described in the Connectors QA Guideline, verifies that manual override allows the selection of the expected type.

  • -testOverrideMetadata_Output(): Idem input.

  • -testPerceptiveFlowDesign(): As described in the Connectors QA Guideline, verifies the Datamapper automatic metadata population is achieved with the expected values.

XmlGenerationTestCases

  • -testXmlAllRequiredSet_DefinedAttributes_NoErrorFound(): Populates the operation required attributes with valid values using the complex type definition of the child elements (if the operation has any).

  • -testXmlAllRequiredSet_ReferencedAttributes_NoErrorFound(): Populates the operation required attributes with valid values using the referenced type definition of the child elements (if the operation has any).

  • -testXmlNoneRequiredSet_ErrorsFound(): Leaves all the required fields empty, so errors should be found.