2424import org .utplsql .api .TestRunner ;
2525import org .utplsql .api .Version ;
2626import org .utplsql .api .exception .SomeTestsFailedException ;
27+ import org .utplsql .api .reporter .CoreReporters ;
2728import org .utplsql .api .reporter .Reporter ;
2829import org .utplsql .api .reporter .ReporterFactory ;
2930import org .utplsql .maven .plugin .helper .PluginDefault ;
@@ -138,21 +139,25 @@ public void execute() throws MojoExecutionException {
138139 try {
139140 FileMapperOptions sourceMappingOptions = buildSourcesOptions ();
140141 FileMapperOptions testMappingOptions = buildTestsOptions ();
141-
142- // Create the Connection to the Database
142+
143143 connection = DriverManager .getConnection (url , user , password );
144- getLog ().info ("utPLSQL Version = " + DBHelper .getDatabaseFrameworkVersion (connection ));
145-
146- List <Reporter > reporterList = initReporters (connection );
147-
144+
145+ Version utlVersion = DBHelper .getDatabaseFrameworkVersion (connection );
146+ getLog ().info ("utPLSQL Version = " + utlVersion );
147+
148+ List <Reporter > reporterList = initReporters (connection , utlVersion , ReporterFactory .createEmpty ());
149+
148150 logParameters (sourceMappingOptions , testMappingOptions , reporterList );
149151
150- TestRunner runner = new TestRunner ().addPathList (paths ).addReporterList (reporterList )
151- .sourceMappingOptions (sourceMappingOptions ).testMappingOptions (testMappingOptions )
152- .skipCompatibilityCheck (skipCompatibilityCheck ).colorConsole (colorConsole )
152+ TestRunner runner = new TestRunner ()
153+ .addPathList (paths )
154+ .addReporterList (reporterList )
155+ .sourceMappingOptions (sourceMappingOptions )
156+ .testMappingOptions (testMappingOptions )
157+ .skipCompatibilityCheck (skipCompatibilityCheck )
158+ .colorConsole (colorConsole )
153159 .failOnErrors (!ignoreFailure );
154-
155- // Setting Optional Parameters
160+
156161 if (StringUtils .isNotBlank (excludeObject )) {
157162 runner .excludeObject (excludeObject );
158163 }
@@ -170,9 +175,9 @@ public void execute() throws MojoExecutionException {
170175 throw new MojoExecutionException (e .getMessage (), e );
171176 } finally {
172177 try {
173- // Write Reporters
174- if (connection != null )
178+ if (null != connection ) {
175179 reporterWriter .writeReporters (connection );
180+ }
176181 } catch (Exception e ) {
177182 getLog ().error (e .getMessage (), e );
178183 }
@@ -205,7 +210,6 @@ private void loadConfFromEnvironment() {
205210 */
206211 private FileMapperOptions buildSourcesOptions () throws MojoExecutionException {
207212 try {
208- // Check if this element is empty
209213 if (sources .isEmpty ()) {
210214 File defaultSourceDirectory = new File (project .getBasedir (),PluginDefault .SOURCE_DIRECTORY );
211215 if (defaultSourceDirectory .exists ()) {
@@ -262,7 +266,6 @@ private FileMapperOptions buildSourcesOptions() throws MojoExecutionException {
262266 */
263267 private FileMapperOptions buildTestsOptions () throws MojoExecutionException {
264268 try {
265- // Check if this element is empty
266269 if (tests .isEmpty ()) {
267270 File defaultTestDirectory = new File (project .getBasedir (),PluginDefault .TEST_DIRECTORY );
268271 if (defaultTestDirectory .exists ()) {
@@ -318,15 +321,18 @@ private FileMapperOptions buildTestsOptions() throws MojoExecutionException {
318321 * @return
319322 * @throws SQLException
320323 */
321- private List <Reporter > initReporters (Connection connection ) throws SQLException {
322- List <Reporter > reporterList = new ArrayList <>();
323-
324- Version utlVersion = DBHelper .getDatabaseFrameworkVersion (connection );
324+ private List <Reporter > initReporters (
325+ Connection connection , Version utlVersion , ReporterFactory reporterFactory ) throws SQLException {
325326
326- // Initialized Reporters
327+ List < Reporter > reporterList = new ArrayList <>();
327328 reporterWriter = new ReporterWriter (targetDir , utlVersion );
328329
329- ReporterFactory reporterFactory = ReporterFactory .createEmpty ();
330+ if (reporters .isEmpty ()) {
331+ ReporterParameter reporterParameter = new ReporterParameter ();
332+ reporterParameter .setConsoleOutput (true );
333+ reporterParameter .setName (CoreReporters .UT_DOCUMENTATION_REPORTER .name ());
334+ reporters .add (reporterParameter );
335+ }
330336
331337 for (ReporterParameter reporterParameter : reporters ) {
332338 Reporter reporter = reporterFactory .createReporter (reporterParameter .getName ());
@@ -358,7 +364,6 @@ private void logParameters(FileMapperOptions sourceMappingOptions, FileMapperOpt
358364 Log log = getLog ();
359365 log .info ("Invoking TestRunner with: " + targetDir );
360366
361- // Do nothing when the debug is disabled
362367 if (!log .isDebugEnabled ()) {
363368 return ;
364369 }
0 commit comments