(Just repeating what Vincent wrote already)

When you invoke 'mvn test', you tell maven to run the default lifecycle up
to phase 'test', which _already_ includes the phases 'compile' and
'test-compile'. Check that link to the lifecycle documentation.

In your case, you probably used an older version of the compiler plugin or
had not activated the incremental compilation - which would explain why the
test-compile phase did nothing. You could check your build log for the
"nothing to compile" message (or something like that).

In order to be sure that everything is up-to-date, also invoke the 'clean'
phase of the 'clean' lifecycle: 'mvn clean test'.



2013/11/19 Andrew Pennebaker <[email protected]>

> Thanks all, that helps!
>
> In the future, could `mvn test` automatically call `mvn test-compile` every
> time, in case src/main/ code has changed that affects src/test/ code?
>
>
> On Tue, Nov 19, 2013 at 1:09 PM, Vincent Latombe
> <[email protected]>wrote:
>
> > Hi,
> > you should use mvn clean test to make sure compilation happens everytime.
> > Otherwise, you can check recent versions of maven-compiler-plugin (3.1)
> > which introduced some incremental compilation support [1].
> >
> > And yes, mvn compile will only compile main source code, you should check
> > the lifecycle reference [2]
> >
> > [1]
> >
> >
> http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#useIncrementalCompilation
> > [2]
> >
> >
> http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference
> >
> > Vincent
> >
> >
> > 2013/11/19 Andrew Pennebaker <[email protected]>
> >
> > > I was refactoring some code, when I noticed unit test errors to do with
> > > missing methods, as I had forgotten to also refactor my unit tests.
> These
> > > sorts of errors should have been caught at compile time, but `mvn test`
> > was
> > > blissfully running the tests anyway.
> > >
> > > How can I force `mvn compile` to compile src/test/java/**.java files as
> > > well?
> > >
> > > --
> > > Cheers,
> > >
> > > Andrew Pennebaker
> > > [email protected]
> > >
> >
>
>
>
> --
> Cheers,
>
> Andrew Pennebaker
> [email protected]
>

Reply via email to