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.BlockJUnit4ClassRunner

This 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)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
    Check if we are running this test in an Alfresco server instance.
    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.
    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.
    protected static Object
     
    protected void
    runChild(org.junit.runners.model.FrameworkMethod method, org.junit.runner.notification.RunNotifier notifier)
     
    static String
     

    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

    Methods inherited from class org.junit.runner.Runner

    testCount

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • AlfrescoTestRunner

      public AlfrescoTestRunner(Class<?> klass) throws org.junit.runners.model.InitializationError
      Throws:
      org.junit.runners.model.InitializationError
  • Method Details

    • 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:
      runChild in class org.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 run
      notifier - given @RunNotifier to notify the result of the test
      desc - given @Description of the test to run
    • objectFromString

      protected static Object objectFromString(String string) throws IOException, ClassNotFoundException
      Throws:
      IOException
      ClassNotFoundException
    • 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 @FrameworkMethod to be executed
      Returns:
      the ACS endpoint