This git project is the exercise we are following in our workshop 'Automated end-to-end Tests and other Legendary Creatures'.
We are going to implement 4 parts, that correspond with the 4 parts a test should ideally have:
- Preparation
- Execution
- Assertion
- Clean up the environment
First step is to prepare an environment to run automation against it. It's going to be our Liferay customization to be tested.
Here we have two possibilities. Download and run our docker image with everything already configured or just import our Amazing Fragment into an already running liferay instance (Liferay 7.1 or higher). We recommend using our docker container.
You can to download and install an already configured docker container with a customized instance of Liferay inside.
In order to do it, just follow:
- Install docker https://docs.docker.com/get-docker/
- Increase your Memory in docker to at least 6.00 GB (settings-> Resources -> Advanced -> Memory)
- In a console just run (please note you can change the port and select another one instead of 8080)
docker run --name my-local-liferay-test --rm -p 8080:8080 dgutimesa/my-test:7.4.3.10-ga10
- Import My Amazing Fragment
- Create a private content page and call "My Amazing Page". Add the imported fragment. Publish it.
- If you are running 7.2 or older, go to java/utils/APIs/Company.java file in this automation project, remove comment for line 19 and comment out lines 24 to 29.
- If you are running 7.3 or newer, login as admin in Liferay portal, go to "Instance Settings > User Authentication" and uncheck "Require strangers to verify their email address?"
Also clone this repo and open it with your favorite IDE (we are going to use IntellJ IDEA to show it)
We recommend you to install some plugin for Java, Gradle and Cucumber.
We also recommend having installed Chrome browser. Otherwise, you will need to pass the browser you want to use when executing the tests.
After install the docker image and clone this repo, in order to run the tests in a console you must just do (please mind if you need to use a the port or not):
./gradlew :cleanTest :test
Or execute test runner java file RunTests.java from your ID.
We just need to run "cucumber" task with Gradle and option -Durl in the root project folder. Example:
./gradlew :cleanTest :test -Durl=http://localhost:9080/
By default, tests are executed against localhost with http protocol and using port 8080.
If you want to run against another instance you have access to can use the flag -Durl=protocol://url:port/. You must specify the three of them: protocol + url + port.
For example, to run against 192.168.40.58 with protocol http and port 7300, just use:
./gradlew :cleanTest :test -Durl=http://192.168.40.58:7300/
Default browser is Chrome. To run in another browser, we need to have it installed in our OS and use -Dbrowser=browserName flag.
For example, to run with FireFox, just use:
./gradlew :cleanTest :test -Dbrowser=firefox
IF we want to ru our tests in a continuous integration environment we can add the flag -Dci=true. This will run browsers headless. If we don't set it, or we set any other value than true, test are executed in normal mode.
Use example:
./gradlew :cleanTest :test -Dci=true
After test execution, a basic HTML report is automatically generated in ./target/ folder.
If you have any further question, just email me us to [email protected] or [email protected]