Package org.xwiki.rendering.test.cts
Class CompatibilityTestSuite
- java.lang.Object
-
- org.junit.runner.Runner
-
- org.junit.runners.ParentRunner<org.junit.runner.Runner>
-
- org.junit.runners.Suite
-
- org.xwiki.rendering.test.cts.CompatibilityTestSuite
-
- All Implemented Interfaces:
org.junit.runner.Describable
,org.junit.runner.manipulation.Filterable
,org.junit.runner.manipulation.Orderable
,org.junit.runner.manipulation.Sortable
public class CompatibilityTestSuite extends org.junit.runners.Suite
Run all tests found in resources files located in the classpath, for a given Syntax. The algorithm is the following:- Look for
cts/[scope]
resources in the classpath where[scope]
represents the value of the@Scope
annotation prefixed bycts\\.
. By default if no Scope annotation is defined,.*\\.xml
is used, leading to a total regex ofcts\\..*\\.xml
. This is the regex that's used to look for resources in the classpath. For example the following test file would match:cts/simple/bold/bold1.inout.xml
. We call theseCTS
resources. - For each
CTS
resource found look for equivalent test input and output files for the tested Syntax. For example if we havects/simple/bold/bold1.inout.xml
then if the Syntax isxwiki/2.0
look forxwiki20/simple/bold/bold1.[in|out|inout].txt
test files. We call themSYN
resources. - For each
SYN IN
resource, parse it with the corresponding Syntax parser and render the generated XDOM with the CTS Renderer, and compare the results with theCTS OUT
resource. Note that if noSYN IN
resource is found generate a warning in the test logs. - For each
SYN OUT
resource, parse theCTS IN
resource with the CTS Syntax parser and render the generated XDOM with the Syntax Renderer, and compare the results with theSYN OUT
resource. Note that if noSYN OUT
resource is found generate a warning in the test logs.
Usage Example
@RunWith(CompatibilityTestSuite.class) @Syntax("xwiki/2.0") @Scope("simple") public class IntegrationTests { }
It's also possible to get access to the underlying Component Manager used, for example in order to register Mock implementations of components. For example:
@RunWith(CompatibilityTestSuite.class) @Syntax("xwiki/2.0") @Scope("simple") public class IntegrationTests { @Initialized public void initialize(ComponentManager componentManager) { // Init mocks here for example } }
- Since:
- 4.1M1
- Version:
- $Id: d7b8432b89dd84bc83464de880868a8c331949f9 $
-
-
Constructor Summary
Constructors Constructor Description CompatibilityTestSuite(Class<?> klass)
Only called reflectively.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected List<org.junit.runner.Runner>
getChildren()
org.junit.runner.Description
getDescription()
-
Methods inherited from class org.junit.runners.ParentRunner
childrenInvoker, classBlock, classRules, collectInitializationErrors, createTestClass, filter, getName, getRunnerAnnotations, getTestClass, isIgnored, order, run, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods, withAfterClasses, withBeforeClasses, withInterruptIsolation
-
-
-
-
Constructor Detail
-
CompatibilityTestSuite
public CompatibilityTestSuite(Class<?> klass) throws Exception
Only called reflectively. Do not use programmatically.- Parameters:
klass
- the test instance class on which this Test Suite is applied- Throws:
Exception
- if we fail to locate or load test data, if theRenderingTest
isn't a valid JUnit Test class or if we cannot locate the Component Manager
-
-
Method Detail
-
getChildren
protected List<org.junit.runner.Runner> getChildren()
- Overrides:
getChildren
in classorg.junit.runners.Suite
-
getDescription
public org.junit.runner.Description getDescription()
We override this method so that the JUnit results are not displayed in a test hierarchy with a single test result for each node (as it would be otherwise since RenderingTest has a single test method).
- Specified by:
getDescription
in interfaceorg.junit.runner.Describable
- Overrides:
getDescription
in classorg.junit.runners.ParentRunner<org.junit.runner.Runner>
-
-