๐พ Back to TAS Master Documentation
- Synopsis
- Prerequisite
- Installation
- Package Presentation
- Sample Usage
- Listeners
- Test Results
- Test Rail Integration
- Change Log :glowing_star:
- Reference
- Contributors
- License
TAS( Test Automation System)- WebDAV is the project that handles the automated tests related only to WebDAV protocol integrated with Alfresco One Alfresco WebDAV protocol.
It is based on Apache Maven, compatible with major IDEs and is using also Spring capabilities for dependency injection.
As a high level overview, this project makes use of the following functionality useful in automation testing as:
- reading/defining test environment settings (e.g. alfresco server details, authentication, etc.)
- managing resource (i.e. creating files and folders)
- test data generators (for site, users, content, etc)
- helpers (i.e. randomizers, test environment information)
- test logging generated on runtime and test reporting capabilities
- test management tool integration (at this point we support integration with Test Rail (v5.2.1)
- health checks (verify if server is reachable, if server is online)
- generic Internal-DSL (Domain Specific Language)
Using Nexus -Release Repository, everyone will be able to use individual interfaces in their projects by extending the automation core functionalities.
(tested on unix/non-unix destribution)
- Java SE 1.8.
- Maven 3.3 installed and configure according to Windows OS or Mac OS.
- Configure Maven to use Alfresco alfresco-internal repository following this Guide.
- Your favorite IDE as Eclipse or InteliJ.
- Access to Nexus repository.
- Access to Gitlab TAS repository.
- GitLab client for your operating system. (we recommend SourceTree - use your google account for initial setup).
- Getting familiar with Basic Git Commands.
- Getting familiar with Maven.
- Getting familiar with Spring.
- Getting familiar with TestNG
- Install Davfs utility on your test environment (if is linux)
- Open your Gitlab client and clone the repository of this project.
- You can do this also from command line (or in your terminal) adding:
$ git clone https://gitlab.alfresco.com/tas/alfresco-tas-webdav-test.git
$
# this clone will have the latest changes from repository. If you want to checkout a specific version released, take a look at the [Change Log](docs/CHANGELOG.md) page
$ cd alfresco-tas-webdav-test
# this command will checkout the remove v1.0.0 tagged repository and create locally a new branch v1.0.0
$ git checkout tags/v1.0.0 -b v1.0.0
- Install and check if all dependencies are downloaded
> mvn clean install -DskipTests
# you should see one [INFO] BUILD SUCCESS message displayed
The project uses a maven layout archetype:
โโโ pom.xml
โโโ src
โย ย โโโ main
โย ย โย ย โโโ java
โย ย โย ย โโโ org
โย ย โย ย โโโ alfresco
โย ย โย ย โโโ webdav
โย ย โย ย โโโ dsl
โ โ โ โโโ JmxUtil.java
โ โ โ โโโ WebDavAssertion.java
โ โ โ โโโ WebDavNetworkDrive.java
โ โ โ โโโ WebDavUtil.java
โย ย โย ย โโโ WebDavProperties.java #handles all properties from default.properties
โย ย โย ย โโโ WebDavWrapper.java #wrapper around WebDAV protocol
โย ย โโโ test
โย ย โย ย โโโ java
โย ย โย ย โย ย โโโ org
โย ย โย ย โย ย โโโ alfresco
โย ย โย ย โย ย โโโ webdav
โ โ โ โโโ CopyTests.java
โ โ โ โโโ CreateFileTests.java
โ โ โ โโโ CreateFolderTests.java
โ โ โ โโโ (...)
โ โ โ โโโ WebDavDemoTest.java #demo example
โย ย โย ย โย ย โโโ WebDavRootTests.java
โย ย โย ย โย ย โโโ WebDavTest.java #abstract base class that should be inherited by all tests
โย ย โย ย โโโ resources
โย ย โย ย โโโ alfresco-webdav-context.xml #spring configuration
โย ย โย ย โโโ default.properties #all settings related to environment, protocol
โย ย โย ย โโโ log4j.properties
Following the standard layout for Maven projects, the application sources locate in src/main/java and test sources locate in src/test/java. Application sources consist in defining the WebDAV object that simulates the actions for this protocol. The tests are based on an abstract object: WebDavTest.java that handles the common behavior: checking the health status of the test server, configuration settings, getting the general properties, etc.
Please take a look at WebDavDemoTest.java class for an example.
Common configuration settings required for this project are stored in properties file, see default.properties. Please analyze and update it accordingly with Alfresco test server IP, port, credentials, etc.
Example:
# Alfresco HTTP Server Settings
alfresco.scheme=http
alfresco.server=<add-here-the-ip-of-your-test-server>
alfresco.port=<default-port-for-alfresco-not-share>
- optional update the logging level in log4j file (you can increase/decrease the details of the logging file, setting the
log4j.rootLogger=DEBUG
if you want.) - go to running section for more information on how to run this tests.
-
Tests are organized in java classes and located on src/test/java as per maven layout.
-
One test class should contain the tests that cover one functionality as we want to have a clear separation of test scope: tests for sanity/core/full, tests that verify manage of folder/files etc.
-
These are the conventions that need to follow when you write a test:
-
The test class has @Test annotation with the group defined: protocols, webdav. You can add more groups like sanity, regression
@Test(groups={"protocols", "webdav", "sanity"}
-
The test has @TestRail annotation in order to assure that the details and results will be submitted on TestRail. The fields for TestRail annotation will be explained on next chapter.
@TestRail(section = { "protocols", "webdav" }, executionType=ExecutionType.SANITY, description = "Verify admin user creates folder in DocumentLibrary with WebDAV") public void adminShouldCreateFolderInSite() throws Exception { webDAVProtocol.usingSite(testSite).createFolder(testFolder).assertExistsInRepo(); }
```
-
Use Spring capabilities to initialize the objects(Models, Wrappers) with @Autowired
-
We followed Builder pattern to develop specific DSL for simple and clear usage of protocol client in test:
webDAVProtocol.usingSite(testSite) .createFolder(testFolder) .assertExistsInRepo();
* To view a simple class that is using this utility, just browse on [WebDavDemoTest.java](src/test/java/org.alfresco.webdav.WebDavDemoTest.java) Notice the class definition and inheritance value: ```java public class WebDavDemoTest extends WebDavTest
- the test name are self explanatory:
@TestRail(section = { "protocols", "webdav" }, executionType=ExecutionType.SANITY, description = "Verify admin user creates folder in DocumentLibrary with WebDAV") public void adminShouldCreateFolderInSite() throws Exception { webdavProtocol.usingSite(testSite) .createFolder(testFolder) .assertExistsInRepo(); }
-
-
The project can be imported into a development environment tool (Eclipse or IntelliJ). You have the possibility to execute tests or suite of tests using TestNG plugin previously installed in IDE.
-
In case you are using the default settings that points to localhost (127.0.0.1) and you don't have Alfresco installed on your machine, you will see one exception thrown (as expected):
org.alfresco.utility.exception.ServerUnreachableException: Server {127.0.0.1} is unreachable.
-
In terminal or CMD, navigate (with CD) to root folder of your project (you can use the sample project):
The tests can be executed on command line/terminal using Maven command
mvn test
This command with trigger the tests specified in the default testng suite from POM file: src/test/resources/sanity-suite.xml
You can use -Dtest parameter to run the test/suites through command line (http://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html).
You can also specify a different suiteXMLFile like:
mvn test -DsuiteXmlFile=src/resources/your-custom-suite.xml
Or even a single test:
mvn test -Dtest=org.alfresco.webdav.WebDavDemoTest
But pay attention that you will not have enabled all the listeners in this case (the Reporting listener or TestRail integration one)
With the help of Listeners we can modify the behaviour of TestNG framework. There are a lot of testNG listener interfaces that we can override in order to provide new functionalities. The tas framework provides out of the box a couple of listeners that you could use. These could be enabled and added at the class level or suite level.
-
if added at the class level:
@Listeners(value=HtmlReportListener.class) public class MyTestClass extends WebDavTest { (...) }
-
or suite xml level
<suite name="Your Suite test" parallel="classes"> <listeners> <listener class-name="org.alfresco.utility.report.HtmlReportListener"></listener> </listeners> (...) </suite>
It will automatically generate one html named "report.html" in ./target/reports folder. Please also take a look at Test Results section.
It will automatically update Test Rail application with the test cases that you've automated. Please take a look at Test Rail Integration section for more details.
This is a new listener that will generate further details in one XML format of the automated test steps that you will write.
Example:
public void myDSLMethod1()
{
STEP("Lorem ipsum dolor sit amet");
//code for first step
STEP("consectetur adipiscing elit");
//code for the next description
}
public void myDSLMethod2()
{
STEP("sed do eiusmod tempor incididunt ut labore");
//code for first step
STEP("et dolore magna aliqua");
//code for the next description
}
If these methods will be executed insite a test method, all those steps will be automatically logged in the XML report generated. Example:
@Test
public void adminShouldCreateFileInSite()
{
myDSLMethod1();
myDSLMethod2()
}
So if "testingSomething" will be executed this is what you will see on the XML file generated. (please take a look at Test Results section for defining the defaul location)
Here is one example of XML file generated with these steps:
We already executed a couple of tests using command line as indicated above. Sweet! Please take a look at webdav-suites.xml one more time. You will see there that we have one listener added:
<listener class-name="org.alfresco.utility.report.HtmlReportListener"></listener>
This will tell our framework, after we run all tests, to generate one HTML report file with graphs and metrics.
Take a look at the target/reports folder (created after running the tests) and open the report.html file.
Playing with this report, you will notice that you will be able to: * search tests cases by name * filter test cases by errors, labels, groups, test types, date when it was executed, protocol used, etc. * view overall pass/fail metrics of current test suite, history of tests execution, etc.
The report path can be configured in default.properties):
```
# The location of the reports path
reports.path=your-new-location-of-reports
```
Alfresco is using now https://alfresco.testrail.net (v5.3.0.3601).
We aim to accelerate the delivery of automated test by minimizing the interaction with the test management tool - TestRail. In this scope we developed the following capabilities:
- creating automatically the manual tests in TestRail
- submitting the test results (with stack trace) after each execution into TestRail Test Runs
- adding the test steps for each test.
In order to use Test Rail Integration you will need to add a couple of information in default.properties file: (the document is pretty self explanatory)
# Example of configuration:
# ------------------------------------------------------
# testManagement.enabled=true
# testManagement.endPoint=https://alfresco.testrail.com/
# testManagement.username=<yourusername-that-you-connect-to-testrail>
# testManagement.apiKey=<api-key>
# testManagement.includeOnlyTestCasesExecuted=true
# testManagement.rateLimitInSeconds=<number-of-seconds>
# testManagement.project=<id-of-your-project
# testManagement.testRun=<test-run-name>
!This settings are already defined in default.properties for you.
For generating a new API Key take a look at the official documentation, TestRail APIv2
- testManagement.project= <id-of-your-project this is the ID of the project where you want to store your test cases. If you want to use Alfresco ONE project in TestRail, open that project and notice the URL, after "/overview/1" link you will see the ID of the project (1 in this case) If you want to use TAS Project you will notice the ID 7, so "testManagement.project=7"
- "testManagement.testRun=" this represents the name of the Test Run from your project.
- In Test Rail, navigating to Test Runs & Results, create a new Test Run and include all/particular test cases. If this test run name is "Automation", update testManagement.testRun= Automation. All test results will be updated only on this test run at runtime as each test is executed by TAS framework.
We wanted to simplify the Test Rail integration, so we used listeners in order to enable/disable the integration of Test Rail.
-
first configure your default.properties as indicated above
-
now on your TestNG test, add the @TestRail annotation, so let's say you will have this test:
@Test(groups="sample-tests") public void thisAutomatedTestWillBePublishedInTestRail() { }
add now @TestRail integration with mandatory field
section
. This means that this tests annotated, will be uploaded in TestRail:@Test(groups="sample-tests") @TestRail(section = { "protocols", "TBD" }) public void thisAutomatedTestWillBePublishedInTestRail() { }
The section field, represents an array of strings, the hierarchy of sections that SHOULD be found on TestRail under the project you've selected in default.properties. Follow the TestRail user-guide for more information regarding sections. In our example we created in Test Rail one root section "protocols" with a child section: "TBD" (you can go further and add multiple section as you wish)
-
now, lets add the listener, the TestRailExecutorListener that will handle this TC Management interaction. This listener can be added at the class level or suite level (approach that we embrace) Take a look at sanity-suite.xml for further example.
<listeners> <listener class-name="org.alfresco.utility.testrail.TestRailExecutorListener"></listener> (...) </listeners>
Right click on sanity-suite.xml file and run it, or just "mvn test" from root if this sample project. After everything passes, go in Test Rail, open your project and navigate to "Test Cases" section. Notice that under protocols/TBD section, you will see your test case published.
If you defined also the "testManagement.testRun" correctly, you will see under Test Runs, the status of this case marked as passed.
The @TestRail annotation offers also other options like:
- "description" this is the description that will be updated in Test Rail for your test case
- "testType", the default value is set to Functional test
- "executionType", default value is set to ExecutionType.REGRESSION, but you can also use ExecutionType.SMOKE, ExecutionType.SANITY, etc
Take a look at the demo scenarios in this project for further examples.
- For any improvements, bugs, please use Jira - TAS project.
- Setup the environment using docker.
- Bamboo Test Plan
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other... more
TBD