Class AlfrescoTestRunner
- java.lang.Object
-
- org.junit.runner.Runner
-
- org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
-
- org.junit.runners.BlockJUnit4ClassRunner
-
- org.alfresco.rad.test.AlfrescoTestRunner
-
- All Implemented Interfaces:
org.junit.runner.Describable,org.junit.runner.manipulation.Filterable,org.junit.runner.manipulation.Orderable,org.junit.runner.manipulation.Sortable
public class AlfrescoTestRunner extends org.junit.runners.BlockJUnit4ClassRunnerThis is a JUnit test runner that is designed to work with an Alfresco repository. It detects if it's executing a test inside of a running Alfresco instance. If that is the case the tests are all run normally. If however the test is being run from outside the repository, from the maven command line or from an IDE such as IntelliJ or STS/Eclipse for example, then instead of running the actual test an HTTP request is made to a Web Script in a running Alfresco instance. This Web Script runs the test and returns enough information to this class so we can emulate having run the test locally.
By doing this, we are able to create Integration Tests (IT) using standard JUnit capabilities. These can then be run from our IDEs with the associated visualizations, support for re-running failed tests, etc.
Integration testing framework donated by Zia Consulting- Since:
- 3.0
- Author:
- Bindu Wavell (bindu@ziaconsulting.com), martin.bergljung@alfresco.com (some editing)
-
-
Constructor Summary
Constructors Constructor Description AlfrescoTestRunner(Class<?> klass)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanareWeRunningInAlfresco()Check if we are running this test in an Alfresco server instance.protected voidcallProxiedChild(org.junit.runners.model.FrameworkMethod method, org.junit.runner.notification.RunNotifier notifier, org.junit.runner.Description desc)Call a remote Alfresco server and have the test run there.protected StringgetContextRoot(org.junit.runners.model.FrameworkMethod method)Check the @Remote config on the test class to see where the Alfresco Repo is running.protected static ObjectobjectFromString(String string)protected voidrunChild(org.junit.runners.model.FrameworkMethod method, org.junit.runner.notification.RunNotifier notifier)static StringserializableToString(Serializable serializable)-
Methods inherited from class org.junit.runners.BlockJUnit4ClassRunner
collectInitializationErrors, computeTestMethods, createTest, createTest, describeChild, getChildren, getTestRules, isIgnored, methodBlock, methodInvoker, possiblyExpectingExceptions, rules, testName, validateConstructor, validateFields, validateInstanceMethods, validateNoNonStaticInnerClass, validateOnlyOneConstructor, validateTestMethods, validateZeroArgConstructor, withAfters, withBefores, withPotentialTimeout
-
Methods inherited from class org.junit.runners.ParentRunner
childrenInvoker, classBlock, classRules, createTestClass, filter, getDescription, getName, getRunnerAnnotations, getTestClass, order, run, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods, withAfterClasses, withBeforeClasses, withInterruptIsolation
-
-
-
-
Field Detail
-
SUCCESS
public static final String SUCCESS
- See Also:
- Constant Field Values
-
FAILURE
public static final String FAILURE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AlfrescoTestRunner
public AlfrescoTestRunner(Class<?> klass) throws org.junit.runners.model.InitializationError
- Throws:
org.junit.runners.model.InitializationError
-
-
Method Detail
-
serializableToString
public static String serializableToString(Serializable serializable) throws IOException
- Throws:
IOException
-
runChild
protected void runChild(org.junit.runners.model.FrameworkMethod method, org.junit.runner.notification.RunNotifier notifier)- Overrides:
runChildin classorg.junit.runners.BlockJUnit4ClassRunner
-
callProxiedChild
protected void callProxiedChild(org.junit.runners.model.FrameworkMethod method, org.junit.runner.notification.RunNotifier notifier, org.junit.runner.Description desc)Call a remote Alfresco server and have the test run there.- Parameters:
method- the test method to runnotifier- given @RunNotifierto notify the result of the testdesc- given @Descriptionof the test to run
-
objectFromString
protected static Object objectFromString(String string) throws IOException, ClassNotFoundException
- Throws:
IOExceptionClassNotFoundException
-
areWeRunningInAlfresco
protected boolean areWeRunningInAlfresco()
Check if we are running this test in an Alfresco server instance.- Returns:
- true if we are running in an Alfresco server
-
getContextRoot
protected String getContextRoot(org.junit.runners.model.FrameworkMethod method)
Check the @Remote config on the test class to see where the Alfresco Repo is running. If it is not present, check the ACS_ENDPOINT_PROP system property as an alternative location. If none of them has a value, then return the default location.- Parameters:
method- given @FrameworkMethodto be executed- Returns:
- the ACS endpoint
-
-