/*
 * 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;
    }
}

/*
 * 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;

import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.MojoExecutionException;
import com.jayway.maven.plugins.android.asm.AndroidTestFinder;

import java.io.File;

/**
 * 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 or disables integration test related goals. If <code>true</code> they will be run; if <code>false</code>,
     * they will be skipped. If <code>auto</code>, they will run if any of the classes inherit from any class in
     * <code>junit.framework.**</code> or <code>android.test.**</code>.
     * @parameter expression="${android.enableIntegrationTest}" default-value="auto"
     */
    private String 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() throws MojoFailureException, MojoExecutionException {
        if (mavenTestSkip){
            return false;
        }

        if ("false".equalsIgnoreCase(enableIntegrationTest)){
            return false;
        }

        if ("true".equalsIgnoreCase(enableIntegrationTest)){
            return true;
        }

        if ("auto".equalsIgnoreCase(enableIntegrationTest)){
            return AndroidTestFinder.containsAndroidTests(new File(project.getBuild().getDirectory(), "android-classes"));
        }

        throw new MojoFailureException("enableIntegrationTest must be configured as 'true', 'false' or 'auto'.");

    }
}

Enable automatic check for platformTest classes.