Testing of Java Integration for Web Components
Best practices include:
Following TDD and DRY principles
If the whole fix or feature, or part of its logic can be tested without roundtrip to the client-side, new unit test should be created. Files names are separated by the topic categories they are covering. Creation of the new file is acceptable following the same advices as for .
The technologies / libraries used for the test creation can be found from imports. For example, in existing unit tests of vaadin-button-flow
@Test
annotation is used which lead to org.junit.Test
import.
Good practice would be to follow the existing test structure and naming conventions. For example, action and result mentioned in .
If contribution’s logic need to be tested with roundtrip to the client-side or in conjunction with other components, new integration test need to be added. Start with reviewing the existing structure of the integration-tests
module of the component to which contribution is done. They have similar structure, but more complex component requires more complex tests.
For example, vaadin-grid-flow
also includes frontend
resources to provide custom styling in tests, test grid in a polymer template etc. In addition, it has data
generators and helpers used.
Test
After selecting the page, new test should be added to existing files that are using the same route as . For example, GridFilteringIT.java
is using GridFilteringPage.java
. If page was created instead, new correspondent test file should be created based on the existing ones.
Note | Test Path Remember to update @TestPath when creating a new file to avoid name conflicts and ensure the tests are passing. |
Take a look onto the existing tests and search for the logic that is needed to be implemented in newly created tests.
Examples worth mentioning: