so far so good I managed to get some tests running with the vaadin test bench like it was described in tutorials provided by vaadin.
I wonder however if there is a concept on how to test the generated java part and also the facade java part of custom vaadin components
(build with polymer) completely automated. So I’m looking for a way to just press the “Run Tests” button of a component and want the
component then automatically be started locally on some predefined port followed by performing all the implemented unit tests.
Is a process like that defined somewhere to look it up?
Do I understand it correctly that the whole testbench stuff is made for testing applications and not single components?
We are building flow components using polymer so we basically have three different code parts:
The frontend code (html / css / javascript)
The automatically generated java code
The facade java code extending the generated java code (the code which we actually want to use in vaadin-applications)
The third part is the one for which we want to write unit tests and integration tests using the testbench. If I run the tests I need to be able to “start” the component somehow so that it is accessible for the unit tests on some address and port. And this fully automatically ofcourse. Did I just miss any part in the documentation describing how to start and show components in the browser out of the java side project or do I understand something very wrong?
the main target is to test applications but it’s used to test all our components also.
When you have multiple layers, there are basically two strategies you can adopt:
Test as much as possible on the lowest layer, then only test on the next layer what is added and assume the lower layers work
Only test on the highest layer and test everything at once
The benefit of doing 1. is that you will immediately find problems if you make changes to your frontend code while the benefit of 2. is that you only have to write tests only in one place.
If you test web components on the Polymer level, you use polyserve and some test templates to “deploy” and configure the component you want to test.
Nice, thank you for your reply. I took the example you posted (vaadin-button-flow) and tried to reproduce it for one of my components. So I added a pom.xml to my project:
Now Im running mvn jetty:run -PrunTests and it is starting correctly and I can call it using http://localhost:9998/ranking-bar. But I got an issue here. The ranking bar is not showing up
due to:
GET http://localhost:9998/frontend/bower_components/ranking-bar/src/ranking-bar.html 404 (Not Found)
Do you maybe have an idea what I was missing?
Edit 1:
I was not able to start the vaadin-button-flow to compare the results due to:
[ERROR]
Failed to execute goal on project vaadin-button-flow: Could not resolve dependencies for project com.vaadin:vaadin-button-flow:jar:1.0-SNAPSHOT: Failed to collect dependencies at org.webjars.bowergithub.vaadin:vaadin-button:jar:2.0.1 -> org.webjars.bowergithub.vaadin:vaadin-lumo-styles:jar:1.0.0 -> org.webjars.bowergithub.polymerelements:iron-icon:jar:2.0.1 -> org.webjars.bowergithub.polymerelements:iron-flex-layout:jar:1.3.7: Failed to read artifact descriptor for org.webjars.bowergithub.polymerelements:iron-flex-layout:jar:1.3.7: Could not transfer artifact org.webjars.bowergithub.polymerelements:iron-flex-layout:pom:1.3.7 from/to nexus-snapshots (https://nexus.gfk.com/repository/maven-snapshots/): Failed to transfer file: https://nexus.gfk.com/repository/maven-snapshots/org/webjars/bowergithub/polymerelements/iron-flex-layout/1.3.7/iron-flex-layout-1.3.7.pom. Return code is: 400, ReasonPhrase: Repository version policy: SNAPSHOT does not allow version: 1.3.7. -> [Help 1]
GET http://localhost:9998/frontend/bower_components/ranking-bar/src/ranking-bar.html 404 (Not Found) sounds like you are missing the webjar for ranking-bar or the files are not in the correct folder
But this location is also not existing and still the application can find the vaadin-button.html.
Is there a configuration / annotation / whatever which is telling the application where to find it?
The webjar support maps frontend://bower_components to META-INF/resources/webjars to be able to support both Bower and webjars using the same import path. So frontend://bower_components/vaadin-button/src/vaadin-button.html should be META-INF/resources/webjars/vaadin-button/src/vaadin-button.html in a webjar, and that is found in http://central.maven.org/maven2/org/webjars/bowergithub/vaadin/vaadin-button/2.0.1/vaadin-button-2.0.1.jar
In my case the path is META-INF/resources/webjars/ranking-bar/0.2.0/src/ranking-bar.html so the version is the problem. Need to get rid of that. Thanks.
EDIT
Yes, all this is working very great when removing the version. Thank you very much!