[ 
https://issues.apache.org/jira/browse/SLING-4757?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14567455#comment-14567455
 ] 

Bertrand Delacretaz commented on SLING-4757:
--------------------------------------------

I have now committed your integration tests as well, and updated various things 
to be able to use the coverage reports as per SLING-4760 (revision 1682931).

For this I had to remove the use of easymock, as this caused trouble with the 
jacoco-maven-plugin (which generates coverage reports), probably due to some 
bytecode manipulation, I haven't checked the details. Anyway, the tests look 
simpler to me in this way, and if we need mocking I usually use Mockito which 
seems to play well with jacoco-maven-plugin.

As a result, if you now run {{mvn clean install -P jacoco-report}} you get 3 
test coverage reports as described at SLING-4760 (might require doing an {{mvn 
clean install}} of the sling/parent module for now as that's referred as a 
SNAPSHOT).

Looking at the {{ContentAwareMimeTypeServiceImpl}} coverage report for example, 
we see that the unit tests do not fully test the class [1], but the integration 
tests [2] test the rest so that we get full coverage once the reports are 
merged [3].

I think that's a good example of what we'd like to achieve: close to 100% test 
coverage based on a combination of unit and integration tests, allowing us to 
use integration tests when mocking things becomes too much of a hassle.

This is a very simple module of course, so a basic example, but we'll try to 
reproduce similar results later on beefier modules. Full 100% coverage does not 
always make sense, but in this case it's easy to attain so why not.

Let me know if you can reproduce the same results in your environment, and if 
yes we can move on to improving tests in other modules. I'll discuss which 
modules to tackle next on our dev list.

[1] 
target/site/jacoco-unit/org.apache.sling.commons.contentdetection.internal/ContentAwareMimeTypeServiceImpl.html
[2] 
target/site/jacoco-it/org.apache.sling.commons.contentdetection.internal/ContentAwareMimeTypeServiceImpl.html
[3] 
target/site/jacoco-merged/org.apache.sling.commons.contentdetection.internal/ContentAwareMimeTypeServiceImpl.html

> Improve test coverage and add integration tests to the contentdetection module
> ------------------------------------------------------------------------------
>
>                 Key: SLING-4757
>                 URL: https://issues.apache.org/jira/browse/SLING-4757
>             Project: Sling
>          Issue Type: Improvement
>          Components: Commons
>            Reporter: Bertrand Delacretaz
>            Assignee: Petr Shypila
>         Attachments: 
> FileNameExtractorImpl_Injection_failed__ClassNotFoundException.patch, 
> week2-part1-unit-tests.patch, week2-part2-integration-tests.patch
>
>
> The new SLING-4694 contentdetection module has reasonable test coverage but 
> there are some gaps, and it's also missing some integration tests to verify 
> that the services provided by the bundle are correctly made available in an 
> OSGI environment.
> I'll take this opportunity to ask our GSoC student [~petr.shypila] to expand 
> these tests, as that's a good example of what we're trying to do with his 
> tests improvement project.
> So [~petr.shypila] here's your "mission" ;-)
> Buliding bundles/commons/contentdetection with with -Pjacoco-report and 
> looking at target/site/jacoco/index.html shows that a few things are not 
> tested. The first step is to add the missing unit tests to improve that, 
> maybe provide a first patch with just that.
> Then, we'd like to add integration tests that start this bundle in an OSGi 
> environment and verify that the ContentAwareMimeTypeService and 
> FileNameExtractor services are available and work. No need to duplicate the 
> unit tests, just verify that the services are here and work in a simple case.
> The best way to do this is probably with Pax Exam, the 
> ResourceBundleProviderIT. is a good example of that and there are other 
> examples in our codebase if you search for *IT.java files that contain 
> "pax.exam".
> As usual, try to minimize changes to the pom (except for what's directly 
> related to testing) and to non-test code.
> Feel free to ask if you have any questions of course, either here for minor 
> ones or on the dev list for larger discussions.
> [1]  
> https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/i18n/src/test/java/org/apache/sling/i18n/it/ResourceBundleProviderIT.java



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to