6

I've generated an Android project using the akquinet archetype:

mvn archetype:generate \
-DarchetypeArtifactId=android-with-test \
-DarchetypeGroupId=de.akquinet.android.archetypes \
-DarchetypeVersion=1.0.11 \
-DgroupId=com.foo.bar \
-DartifactId=my-android-project \
-Dpackage=com.foo.bar.android

This archetype creates

  1. a parent project,
  2. myproject project with the actual Android application and
  3. myproject-it with the integration tests.

When I add the following test class into the myproject-it project and run mvn install, I don't get a test failure message.

import org.junit.Assert;
import org.junit.Test;

public class SimCardReaderTest {
    @Test
    public void testGetAvailableSimCards()
    {
        Assert.fail("Not implemented");
    }
}

Hence, the unit test is not executed.

What can I do in order to run unit tests (tests, which do not depend on the Android environment) in a project based on akquinet?

Glory to Russia
  • 17,289
  • 56
  • 182
  • 325
  • I would prefer put POJO JUnit test in application project's src/test/java folder, not application test project's src/main/java folder. – yorkw Jul 16 '13 at 22:14
  • @yorkw That's what I did. But in order for this solution to work, I needed to manually adapt Eclipse's project files, which is not elegant and prone to error. – Glory to Russia Jul 17 '13 at 11:10
  • Check out answer [here](http://stackoverflow.com/questions/15593842/simple-non-api-android-junit-test-in-eclipse-with-android-maven-plugin/17136833#17136833) to see how to configure and run POJO JUnit test in Eclipse. Note that it doesn't requires any extra step if you run `mvn test` from command-line. – yorkw Jul 17 '13 at 11:40
  • @yorkw The problem was that Eclipse didn't recognize `myproject/src/test/java` as a source folder. – Glory to Russia Jul 17 '13 at 11:41
  • @yorkw You may submit your answer (place unit tests into the `myproject` test folder) and I'll accept it (provided that there are no better answers). – Glory to Russia Jul 17 '13 at 11:42
  • The latest M2E plugin should automatically add `src/test/java` as source folder when you create or import project, regardless of whether it actually exist in file system. See answer [here](http://stackoverflow.com/questions/11976223/how-to-deal-with-missing-src-test-java-source-folder-in-android-maven-project/11978134#11978134) for more details. – yorkw Jul 17 '13 at 11:47

0 Answers0