karaf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Campbell <pcampb...@kemitix.net>
Subject RE: Unit tests and refactoring - karaf-maven-plugin - AssemblyMojo
Date Tue, 18 Apr 2017 21:44:32 GMT


Here is a progress update on my work with AssemblyMojo.

I've been writing some exploratory tests to lock down the current behaviour of the AssemblyMojo.

1/ Split AssemblyMojo into a parameter/configuration class and a behaviour class

I have extracted the doExecute() method and supporting methods out of AssemblyMojo and into
AssemblyMojoExec. (That probably needs a better name: AssemblyService?). This left all the
@Parameter fields in AssemblyMojo, which is now passed as a single parameter object: AssemblyMojoExec.doExecute(AssemblyMojo
mojo). This gives a clean separation between capturing 39 @Parameters and performing the actual

2/ Upgraded Maven in the tooling package to 3.5.0

This allows simplification of accessing the Maven API and avoids the need to use reflection.
Upgrading the rest of karaf is outside the current scope.

3/ Added jacoco for code coverage, without any minimum coverage requirements

Jacoco is licensed under Eclipse Public License Version 1.0.

4/ Added mockito for test support

Mockito is licensed under M.I.T. License.

5/ Added hamcrest for test support

Hamcrest is licensed under BSD License.

6/ Write tests for AssemblyMojoExec covering 86% of branches.

The remaining 14% of branches are in unreachable File IO or Reflection exceptions and in switch statements.

7/ Identify unused @Parameters

The following @Parameter fields in AssemblyMojo are unused and could be removed without affecting
the tests.
* featuresCfgFile
* startupPropertiesFile​​​​​​​
* systemDirectory
* defaultStartLevel
* blacklistedRepositories
* blacklistedFeatures
* startupBundles
* bootBundles
* installedBundles
* blacklistedBundles
* blacklistedProfiles

Is there any reason to keep any of these @Parameters? They are configuration items used by
other Mojos. AssemblyMojo should really only ask for the @Parameters that it uses.


This current state is in https://github.com/kemitix/karaf/tree/assembly-mojo-test-coverage

Going on from here, I will be working in the assembly-mojo-refactoring branch to clean up
and simplify the mojo, using the AssemblyMojoExecTest to ensure that behaviour remains consistent.
Feedback welcome.
Paul [W] Campbell  

If you reply to this email, your message will be added to the discussion below: http://karaf.922171.n3.nabble.com/Unit-tests-and-refactoring-karaf-maven-plugin-AssemblyMojo-tp4050098p4050113.html
To unsubscribe from Unit tests and refactoring - karaf-maven-plugin - AssemblyMojo, click
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message