Demonstrates how to build tests of different levels (unit, component, system) for apps with rich client. Technologies:
- Spring MVC, Hibernate; Groovy JUnit, Spock, 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-domaincontains logic to store/retrieve data to/from DB
test-pyramid-webcontains 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).
src/test folders with Groovy 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/testcontains Unit and Component tests
test-pyramid-web/src/testcontains 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 testwould 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 -DrunSystemTestswill 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. Issue
mvn packagefrom root folder to generate
test-pyramid-web/target/test-pyramid-web***.warthat 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.
- Mock to be started at random port when running component tests
- Create Allure reports
- Generate coverage metrics
- Create sample CD Pipeline in Jenkins