You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by 建文 <to...@163.com> on 2015/08/30 15:40:45 UTC

Can not build with Junit4.18

I add junit4.8 in my project, and the test java classes are in 
src/main/java not src/test/java(i know it's not best practice),
and i set junit dependency scope to runtime.
but when i run mvn clean install -DskipTests=ture,got error,

[ERROR] Failed to execute goal 
org.apache.maven.plugins:maven-compiler-plugin:3.3:compile 
(default-compile) on project HigoPlatform: Compilation failure: 
Compilation failure:
[ERROR] 
/mydata/project/HigoPlatform/src/main/java/com/higo/test/TestJunit4.java:[3,24] 
package org.junit does not exist
[ERROR] 
/mydata/project/HigoPlatform/src/main/java/com/higo/test/TestJunit4.java:[5,17] 
package org.junit does not exist
[ERROR] 
/mydata/project/HigoPlatform/src/main/java/com/higo/test/TestJunit4.java:[14,4] 
cannot find symbol
[ERROR] symbol:   class Test
[ERROR] location: class com.higo.test.TestJunit4
[ERROR] 
/mydata/project/HigoPlatform/src/main/java/com/higo/test/TestJunit4.java:[16,5] 
cannot find symbol

from error,i try to override the junit version in maven-compiler-plugin 
with:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
                 <version>3.3</version>
                 <configuration>
                     <encoding>UTF-8</encoding>
                     <source>1.7</source>
                     <target>1.7</target>
                 </configuration>
                 <dependencies>
                     <dependency>
                         <groupId>junit</groupId>
                         <artifactId>junit</artifactId>
                         <version>4.12</version>
                     </dependency>
                 </dependencies>
             </plugin>
but not work.any suggest or resolution tip? thanks


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Can not build with Junit4.18

Posted by jian wen <to...@163.com>.
?

Sent from Outlook




On Sun, Aug 30, 2015 at 7:35 AM -0700, "Karl Heinz Marbaise" <kh...@gmx.de> wrote:










Hi,

On 8/30/15 3:40 PM, 建文 wrote:
> I add junit4.8 in my project, and the test java classes are in
> src/main/java not src/test/java(i know it's not best practice),

You should change that and put the tests into src/test/java...

I assume you have given the scope for junit ? If yes than junit is not 
available for src/main/java...
Apart from that a scope of a test dependency to runtime does not make 
sense...for tests it should be "test" scope...

Furthermore your test should be named likt Junit4Test.java instead....to 
follow the naming conventions...


> and i set junit dependency scope to runtime.
> but when i run mvn clean install -DskipTests=ture,got error,
>
> [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-compiler-plugin:3.3:compile
> (default-compile) on project HigoPlatform: Compilation failure:
> Compilation failure:
> [ERROR]
> /mydata/project/HigoPlatform/src/main/java/com/higo/test/TestJunit4.java:[3,24]
> package org.junit does not exist
> [ERROR]
> /mydata/project/HigoPlatform/src/main/java/com/higo/test/TestJunit4.java:[5,17]
> package org.junit does not exist
> [ERROR]
> /mydata/project/HigoPlatform/src/main/java/com/higo/test/TestJunit4.java:[14,4]
> cannot find symbol
> [ERROR] symbol:   class Test
> [ERROR] location: class com.higo.test.TestJunit4
> [ERROR]
> /mydata/project/HigoPlatform/src/main/java/com/higo/test/TestJunit4.java:[16,5]
> cannot find symbol
>
> from error,i try to override the junit version in maven-compiler-plugin
> with:
> 
> org.apache.maven.plugins
> maven-compiler-plugin
>                  3.3
>                  
>                      UTF-8
>                      1.7
>                      1.7
>                  
>                  
>                      
>                          junit
>                          junit
>                          4.12
>                      
>                  
>              
> but not work.any suggest or resolution tip? thanks
>


Junit ist not a plugin dependency it's a usual dependency...which means 
to add it as this:


   
     junit
     junit
     4.12
   


which is also a contradiction to the subject of the thread...

Kind regards
Karl Heinz Marbaise

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org

Re: Can not build with Junit4.18

Posted by Karl Heinz Marbaise <kh...@gmx.de>.
Hi,

On 8/30/15 3:40 PM, 建文 wrote:
> I add junit4.8 in my project, and the test java classes are in
> src/main/java not src/test/java(i know it's not best practice),

You should change that and put the tests into src/test/java...

I assume you have given the scope for junit ? If yes than junit is not 
available for src/main/java...
Apart from that a scope of a test dependency to runtime does not make 
sense...for tests it should be "test" scope...

Furthermore your test should be named likt Junit4Test.java instead....to 
follow the naming conventions...


> and i set junit dependency scope to runtime.
> but when i run mvn clean install -DskipTests=ture,got error,
>
> [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-compiler-plugin:3.3:compile
> (default-compile) on project HigoPlatform: Compilation failure:
> Compilation failure:
> [ERROR]
> /mydata/project/HigoPlatform/src/main/java/com/higo/test/TestJunit4.java:[3,24]
> package org.junit does not exist
> [ERROR]
> /mydata/project/HigoPlatform/src/main/java/com/higo/test/TestJunit4.java:[5,17]
> package org.junit does not exist
> [ERROR]
> /mydata/project/HigoPlatform/src/main/java/com/higo/test/TestJunit4.java:[14,4]
> cannot find symbol
> [ERROR] symbol:   class Test
> [ERROR] location: class com.higo.test.TestJunit4
> [ERROR]
> /mydata/project/HigoPlatform/src/main/java/com/higo/test/TestJunit4.java:[16,5]
> cannot find symbol
>
> from error,i try to override the junit version in maven-compiler-plugin
> with:
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-compiler-plugin</artifactId>
>                  <version>3.3</version>
>                  <configuration>
>                      <encoding>UTF-8</encoding>
>                      <source>1.7</source>
>                      <target>1.7</target>
>                  </configuration>
>                  <dependencies>
>                      <dependency>
>                          <groupId>junit</groupId>
>                          <artifactId>junit</artifactId>
>                          <version>4.12</version>
>                      </dependency>
>                  </dependencies>
>              </plugin>
> but not work.any suggest or resolution tip? thanks
>


Junit ist not a plugin dependency it's a usual dependency...which means 
to add it as this:

<dependencies>
   <dependency>
     <groupId>junit</groupId>
     <artifactId>junit</artifactId>
     <version>4.12</version>
   </dependency>
</dependencies>

which is also a contradiction to the subject of the thread...

Kind regards
Karl Heinz Marbaise

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Can not build with Junit4.18

Posted by Jörg Schaible <jo...@swisspost.com>.
建文 wrote:

> Junit is added in dependencies,and i can run Junit test in my Eclipse,
> but when run mvn clean install -DskipTests=true fail

Maven is about conventions. If you don't follow its conventions, you'll run 
into trouble. Like this.

Maven separates between the main source and the code for test (unlike 
Eclipse) and uses different class paths. JUnit is *only* on the classpath 
for the test code, which is expected by Maven in the subdirectory 
src/test/java.

As long as you insists on violating Maven's conventions (like keeping test 
code in src/main/java), you'll face such problems. That's what peoples tried 
to tell you already.

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Can not build with Junit4.18

Posted by 建文 <to...@163.com>.
Junit is added in dependencies,and i can run Junit test in my Eclipse,
but when run mvn clean install -DskipTests=true fail

On 2015/9/1 23:56, Sandra Parsick wrote:
> Hi,
>
> You have to add the junit dependency in your <dependencies> section.
> But I would recommend you to move the tests to src/test/java.
>
> Best regards,
>
> Sandra
>
> Am 30.08.2015 um 15:40 schrieb 建文:
>> I add junit4.8 in my project, and the test java classes are in
>> src/main/java not src/test/java(i know it's not best practice), and
>> i set junit dependency scope to runtime. but when i run mvn clean
>> install -DskipTests=ture,got error,
>>
>> [ERROR] Failed to execute goal
>> org.apache.maven.plugins:maven-compiler-plugin:3.3:compile
>> (default-compile) on project HigoPlatform: Compilation failure:
>> Compilation failure: [ERROR]
>> /mydata/project/HigoPlatform/src/main/java/com/higo/test/TestJunit4.java:[3,24]
>>
>>
> package org.junit does not exist
>> [ERROR]
>> /mydata/project/HigoPlatform/src/main/java/com/higo/test/TestJunit4.java:[5,17]
>>
>>
> package org.junit does not exist
>> [ERROR]
>> /mydata/project/HigoPlatform/src/main/java/com/higo/test/TestJunit4.java:[14,4]
>>
>>
> cannot find symbol
>> [ERROR] symbol:   class Test [ERROR] location: class
>> com.higo.test.TestJunit4 [ERROR]
>> /mydata/project/HigoPlatform/src/main/java/com/higo/test/TestJunit4.java:[16,5]
>>
>>
> cannot find symbol
>> from error,i try to override the junit version in
>> maven-compiler-plugin with: <plugin>
>> <groupId>org.apache.maven.plugins</groupId>
>> <artifactId>maven-compiler-plugin</artifactId>
>> <version>3.3</version> <configuration> <encoding>UTF-8</encoding>
>> <source>1.7</source> <target>1.7</target> </configuration>
>> <dependencies> <dependency> <groupId>junit</groupId>
>> <artifactId>junit</artifactId> <version>4.12</version>
>> </dependency> </dependencies> </plugin> but not work.any suggest or
>> resolution tip? thanks
>>
>>
>> ---------------------------------------------------------------------
>>
>>
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Can not build with Junit4.18

Posted by Sandra Parsick <sp...@web.de>.
Hi,

You have to add the junit dependency in your <dependencies> section.
But I would recommend you to move the tests to src/test/java.

Best regards,

Sandra

Am 30.08.2015 um 15:40 schrieb 建文:
> I add junit4.8 in my project, and the test java classes are in 
> src/main/java not src/test/java(i know it's not best practice), and
> i set junit dependency scope to runtime. but when i run mvn clean
> install -DskipTests=ture,got error,
> 
> [ERROR] Failed to execute goal 
> org.apache.maven.plugins:maven-compiler-plugin:3.3:compile 
> (default-compile) on project HigoPlatform: Compilation failure: 
> Compilation failure: [ERROR] 
> /mydata/project/HigoPlatform/src/main/java/com/higo/test/TestJunit4.java:[3,24]
>
> 
package org.junit does not exist
> [ERROR] 
> /mydata/project/HigoPlatform/src/main/java/com/higo/test/TestJunit4.java:[5,17]
>
> 
package org.junit does not exist
> [ERROR] 
> /mydata/project/HigoPlatform/src/main/java/com/higo/test/TestJunit4.java:[14,4]
>
> 
cannot find symbol
> [ERROR] symbol:   class Test [ERROR] location: class
> com.higo.test.TestJunit4 [ERROR] 
> /mydata/project/HigoPlatform/src/main/java/com/higo/test/TestJunit4.java:[16,5]
>
> 
cannot find symbol
> 
> from error,i try to override the junit version in
> maven-compiler-plugin with: <plugin> 
> <groupId>org.apache.maven.plugins</groupId> 
> <artifactId>maven-compiler-plugin</artifactId> 
> <version>3.3</version> <configuration> <encoding>UTF-8</encoding> 
> <source>1.7</source> <target>1.7</target> </configuration> 
> <dependencies> <dependency> <groupId>junit</groupId> 
> <artifactId>junit</artifactId> <version>4.12</version> 
> </dependency> </dependencies> </plugin> but not work.any suggest or
> resolution tip? thanks
> 
> 
> ---------------------------------------------------------------------
>
> 
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org