5

In IntelliJ, I am coding a Java Spring project built with maven. For that project, I created some selenium tests to test my web application and they work as intended. Though due to problems with spring annotations I wasn't able to create JUnit tests for my controllers, so I wanted to test them together with selenium.

I can get the code coverage of my JUnit tests just fine, but I haven't achieved the same for the Selenium tests. I tried using the integrated code coverage plugin of IntelliJ, Emma, and JaCoCo, but none of them give me any results.

I have already searched on StackOverflow, but all results I get are either with third-party tools, changing some configuration with my tomcat server + maven (I don't know much about these topics) and again JaCoCo (which doesn't work for me). Isn't there any easy way to achieve this within IntelliJ? JUnit code coverage works too, so why not selenium? Any help would be highly appreciated.

Mate Mrše
  • 7,997
  • 10
  • 40
  • 77
Bread21
  • 51
  • 2
  • Code coverage for UI tests is not really appropriate. UI tests exercise functional requirements, not code. You can exercise all your code without covering all requirements, and vice versa. UI testing is inherently white-box. Think about what value "coverage" can even provide for UI tests. Code needs to be exercised at a much lower level than the UI. (For context, I've been professionally testing UIs for the last several years.) – Lew Bloch Jun 21 '17 at 19:47
  • What kind of issues did you have when trying to unit-test your controllers? And btw, did you try using [spring-test](http://docs.spring.io/spring-framework/docs/current/spring-framework-reference/html/unit-testing.html) (also a [tutorial on developing and testing REST services with Spring](http://spring.io/guides/tutorials/bookmarks/#_testing_a_rest_service)) for this or something else? – Morfic Jun 21 '17 at 19:53
  • 1
    @LewBloch You probably mean GUI-based system testing is inherently black-box testing? Because if you perform white-box testing, coverage can be a helpful measure (see, for instance, [When to use White box Testing in a software or a website?](https://sqa.stackexchange.com/q/7431)). – beatngu13 Jun 25 '17 at 15:29
  • You're absolutely right, it's black box. My mistake. Thank you. – Lew Bloch Jun 25 '17 at 16:03
  • May be too late but why not... Refer to https://stackoverflow.com/q/20904131/9150059 for how part of your question. – Nitb Jun 26 '18 at 14:58

0 Answers0