Demonstrates how to build tests of different levels (unit, component, system) for apps with rich client. Technologies:
- Spring MVC, Hibernate; JUnit, Spring Test
- AngularJS; Karma, Protractor
If you want to read more about the ideology behind it, have a look at Building Test Pyramid to optimize automated testing. Basic vocabulary:
- Unit Tests - check how functions and classes work in isolation
- Component Tests - initialize a big chunk of an app to test them together. Doesn't require real middleware like Application Servers.
- System Tests run against fully deployed app.
- Can create new Pyramids
- Can list created Pyramids
- Can draw different kinds of Pyramid
test-pyramid-domain
contains logic to store/retrieve data to/from DBtest-pyramid-web
contains Controllers and REST Services that listen to UI. It also contains the UI itself: Velocity page (it's a template HTML is generated from) and JS (AngularJS folders mostly follow generally accepted conventions).
Both test-pyramid-domain
and test-pyramid-web
contain src/test
folders with Java and JS tests. In IDE you should
mark sub-folders of those as test sources if you want those to be treated respectively:
test-pyramid-domain/src/test
contains Unit and Component teststest-pyramid-web/src/test
contains Unit, Component and System tests for both Back End and UI
All the tests can be run via Maven (you need to have it installed):
mvn test
would run Unit and Component tests. It will also run UI Component Tests for which you should need to start Selenium WebDriver (sorry for that, maybe in the future it will get started automatically).mvn test -PSystemTests
will trigger Back End and UI System Tests, but before you run it you need to deploy the app at http://localhost:8080 and run Selenium WebDriver. Issuemvn package
from root folder to generatetest-pyramid-web/target/test-pyramid-web***.war
that can be deployed onto Tomcat. Or use IDE.
To work with UI separately and run its tests separately you should treat tests-pyramid-web
as your home - it contains
package.json
which points to other test configs.
(c) Qala