Eclipse not auto-build test code change

1,635 views
Skip to first unread message

yorkw

unread,
Sep 6, 2011, 7:13:19 PM9/6/11
to Robolectric
Hi Robolectric,

I build my android project with maven and Eclipse and do unit-test in
the freaky Android suggested way. I am quite impressed with
Robolectric and trying to integrate it into one of the project I am
currently work on. I have successfully configure my pom, write a
simple unit-test and run it with JUnit in Eclipse. The only problem is
Eclipse does not auto-build the java file under src/test/java, every
time I change the test code in Eclipse, I have to run mvn install in
command-line and get the class files complied and generated under
target/test-classes, then go back to Eclipse to tun it. Have you got
any clue on this?

Thanks,
Y

Chris Van Vranken

unread,
Sep 7, 2011, 12:29:19 AM9/7/11
to robol...@googlegroups.com

Sounds like eclipse build is not configured right. Check that the android java maven builders are checked off in the project properties. And that autobuild is on. Also verify the settings for eclipse that the robolectric website suggests for project setup. And if that fails try mvn eclipse:clean and reimport the eclipse project

Chris

yorkw

unread,
Sep 7, 2011, 7:06:02 PM9/7/11
to Robolectric
Thanks, Chris, I've figured it out.

The problem is that I am adding src/test/java as a source folder into
my existing project directly in Eclipse IDE, at this point, I guess
the ADT plugin (or something sort of) auto configure the settings to
match this to the Android default output directory (target/android-
classes), which is not the directory JUnit is looking for (target/test-
classes).

The workaround is delete the project from eclipse, clean project
folder (.settings, .classpath, .project) then import it as maven
project again. and this point, m2Eclipse plugin is dominant the
project setup, and automatically correct src/test/java point to the
right one target/test-classes.

Somehow mvn clean does not delete all IDE generated directory/files in
a multiple module maven project, of course you can configure maven-
clean-plugin in your pom to delete them properly.
Reply all
Reply to author
Forward
0 new messages