AEM provides a framework for automating tests for your AEM UI. Using the framework, you write and run UI tests directly in a web browser. The framework provides ajavascript API for creating tests.
The AEM test framework uses Hobbes.js, a testing library written in Javascript. The Hobbes.js framework was developed for testing AEM as part of the development process. The framework is now available for public use for testing your AEM applications.
註解:
Refer to the Hobbes.js documentation for full details of the API.
Action | An Action is a specific activity on a web page such as clicking a link or a button. |
Test Case | A Test Case is a specific situation that can be made up of one or more Actions. |
Test Suite | A Test Suite is a group of related Test Cases that together test a specific use case. |
Open the Testing Console to see the registered Test Suites. The Tests panel contains a list of test suites and their test cases.

When opening the console, the Test Suites are listed to the left along with an option to run all of them sequentially. The space to the right shown with a checkered background, is a placeholder for showing page content as the tests run.

Tests Suites can be run individually. When you run a Test Suite, the page changes as the Test Cases and their Actions are executed and the results appear after completion of the test. Icons indicate the results.
A checkmark icon indicates a passed test:


Test Suites execute sequentially in the order that they appear in the console. You can drill down into a test to see the detailed results.

The following procedure steps you through the creation and execution of a Test Suite using We.Retail content, but you can easily modify the test to use a different web page.
For full details about creating your own Test Suites, see the Hobbes.js API documentation.
-
Open CRXDE Lite. (http://localhost:4502/crx/de)
-
Name Type Value categories String[] granite.testing.hobbes.tests dependencies String[] granite.testing.hobbes.testrunner 註解:
AEM Forms only
To test adaptive forms, add the following values to the categories and dependencies. For example:
categories: granite.testing.hobbes.tests, granite.testing.hobbes.af.commons
dependencies: granite.testing.hobbes.testrunner, granite.testing.hobbes.af
-
new hobs.TestSuite("Experience Content Test Suite", {path:"/etc/clientlibs/myTests/myFirstTest/myTestSuite.js"}) .addTestCase(new hobs.TestCase("Navigate to Experience Content") .navigateTo("/content/we-retail/us/en/experience/arctic-surfing-in-lofoten.html") ) .addTestCase(new hobs.TestCase("Hover Over Topnav") .mouseover("li.visible-xs") ) .addTestCase(new hobs.TestCase("Click Topnav Link") .click("li.active a") );