/*
 * Copyright (C) 2009 Jayway AB
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.jayway.maven.plugins.android;

/**
 * For integrationtest related Mojos.
 * 
 * @author hugo.josefson@jayway.com
 */
public abstract class AbstractIntegrationtestMojo extends AbstractAndroidMojo {
    /**
     * -Dmaven.test.skip is commonly used with Maven to skip tests. We honor it too.
     *
     * @parameter expression="${maven.test.skip}" default-value=false
     * @readonly
     */
    private boolean mavenTestSkip;

    /**
     * Enables integration test related goals. If <code>false</code>, they will be skipped.
     * @parameter expression="${android.enableIntegrationTest}" default-value=true
     */
    private boolean enableIntegrationTest;

    /**
     * Whether or not to execute integration test related goals. Reads from configuration parameter
     * <code>enableIntegrationTest</code>, but can be overridden with <code>-Dmaven.test.skip</code>.
     * @return <code>true</code> if integration test goals should be executed, <code>false</code> otherwise.
     */
    protected boolean isEnableIntegrationTest() {
        if (mavenTestSkip){
            return false;
        }

        return enableIntegrationTest;
    }
}

@@ -634,16 +634,210 @@
 droid;%0A%0A
+import org.apache.maven.plugin.MojoFailureException;%0Aimport org.apache.maven.plugin.MojoExecutionException;%0Aimport com.jayway.maven.plugins.android.asm.AndroidTestFinder;%0A%0Aimport java.io.File;%0A%0A
 /**%0A * F
@@ -1248,16 +1248,28 @@
 Enables 
+or disables 
 integrat
@@ -1295,16 +1295,55 @@
 als. If 
+%3Ccode%3Etrue%3C/code%3E they will be run; if 
 %3Ccode%3Efa
@@ -1353,16 +1353,23 @@
 %3C/code%3E,
+%0A     *
  they wi
@@ -1382,16 +1382,172 @@
 skipped.
+ If %3Ccode%3Eauto%3C/code%3E, they will run if any of the classes inherit from any class in%0A     * %3Ccode%3Ejunit.framework.**%3C/code%3E or %3Ccode%3Eandroid.test.**%3C/code%3E.
 %0A     * 
@@ -1617,20 +1617,22 @@
 t-value=
-true
+%22auto%22
 %0A     */
@@ -1644,23 +1644,22 @@
 private 
-boolean
+String
  enableI
@@ -2049,16 +2049,68 @@
 onTest()
+ throws MojoFailureException, MojoExecutionException
  %7B%0A     
@@ -2181,37 +2181,505 @@
     
-return enableIntegrationTest;
+if (%22false%22.equalsIgnoreCase(enableIntegrationTest))%7B%0A            return false;%0A        %7D%0A%0A        if (%22true%22.equalsIgnoreCase(enableIntegrationTest))%7B%0A            return true;%0A        %7D%0A%0A        if (%22auto%22.equalsIgnoreCase(enableIntegrationTest))%7B%0A            return AndroidTestFinder.containsAndroidTests(new File(project.getBuild().getDirectory(), %22android-classes%22));%0A        %7D%0A%0A        throw new MojoFailureException(%22enableIntegrationTest must be configured as 'true', 'false' or 'auto'.%22);%0A
 %0A   

Enable automatic check for platformTest classes.