You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Petr V." <gr...@yahoo.com> on 2008/11/04 19:49:00 UTC

Can I run individual test in maven

When I issue "mvn test" command, all my tests in test directory are executed, what if I need to run some particular test(assuming we have different test classes instead of one big test class). And is it possible in eclipse to run one particular test with m2eclipse ?

Thanks,

Petr



      

Re: Can I run individual test in maven

Posted by "Petr V." <gr...@yahoo.com>.
Thanks Rafael for all your help,

Eventually I resolved the issue.

I am using Eclipse 3.3.2 and my test was importing javax.xml.ws.Endpoint which is JDK 1.5 class.

Now I noticed when I was starting my eclipse I was getting message on console(due to maven plugin)

1/5/08 5:30:04 PM PST: Eclipse is running in a JRE, but a JDK is required
Some Maven plugins may not work when importing projects or updating source folders

I have JDK 1.6 but some how Eclipse was using JDK1.4 internally I guess, right ???

So I edited  eclipse.ini and add 

-vm 
"C:\Program Files\Java\jdk1.6.0_10\bin\javaw.exe"

But it still said eclipse is running in a JRE.

So I edited my short cut for eclipse and defined target as

"C:\eclipse-SDK-3.3.2-win32\eclipse\eclipse.exe"  -vm "C:\Program Files\Java\jdk1.6.0_10\bin\javaw.exe" vmargs -Xmx512m

And then it did not complain that it was running in a JRE and then I run the test and it went fine. 

The error shown by eclipse initially that "No Runnable Methods" was very confusing. It did not help much. Unless maven had shown me message on eclipse console, I would not have guessed what was happening.

Thought things are working fine but Is my reasoning correct ? :-)

Thanks,

Petr

--- On Wed, 11/5/08, Rafael Trestini <tr...@gmail.com> wrote:
From: Rafael Trestini <tr...@gmail.com>
Subject: Re: Can I run individual test in maven
To: "Maven Users List" <us...@maven.apache.org>
Date: Wednesday, November 5, 2008, 8:27 AM

Petr,

Well, is a very strange behavior. If I put "@Test" annotation above
"testApp()" method, it runs on eclipse fine.

Please check the following:
- junit 4.X is in your eclipse build path? (an easy way to see is
looking in "Referenced Library")
- Forget unit test created by maven. It is just a skeleton. Try to
create your own test case, by clicking with right button on
src/test/main, new Junit Test Case. On top of screen select "Junit
4",
and try to run it.

Just a note:
>>  We do not want to extend TestCase because we want to use jdk1.5 and
its annotations.
You shall to know that extends TestCase and using jdk1.5 is not mutual
exclusive, ok? But I understand you ;-)

Rafael

On Tue, Nov 4, 2008 at 9:06 PM, Petr V. <gr...@yahoo.com> wrote:
> Hi Rafael,
>
> I guess I now know the issue. The test case generated by maven for a
project can be run in Eclipse because it extends TestCase class
>
> But if you run following test in eclipse, the eclipse will complain
"No Runnable Methods"  I am using TestRunner Junit 4 and I have junit
4.5 har in my build path as well. We do not want to extend TestCase because we
want to use jdk1.5 and its annotations.
>
> import org.junit.Test;
>
> public class AppTest
> {
>
>     public void testApp()
>     {
>         assertTrue( true );
>     }
> }
>
> Can you please copy the above test in your maven project test directory
and see if it could be run in eclipse.
>
> Thanks,
>
> Petr
>
> --- On Wed, 11/5/08, Rafael Trestini <tr...@gmail.com> wrote:
> From: Rafael Trestini <tr...@gmail.com>
> Subject: Re: Can I run individual test in maven
> To: "Maven Users List" <us...@maven.apache.org>
> Date: Wednesday, November 5, 2008, 2:45 AM
>
> Sorry.. I pressed "send" out of time...
>
> 1. Create a project with archetype:
>   $ mvn archetype:generate
>   // answer the question and archetype will create a skeleton of a
> project for you, with all default parameters
> 2. Put all your java code into /src/main/java
> 3. Put all your non-java code, like configurations, etc, in
/src/main/resources
> 4. Create your junit tests in /src/test/java
> 5. If you need extra configuration for tests, use /src/test/resources for
it
> 6. In pom.xml, change version of dependency with junit to 4.5
> 7. type:
>   $ mvn eclipse:eclipse
> 8. Import your project in eclipse
> 9. Try to run test now.
>
> Rafael Trestini
>
> On Tue, Nov 4, 2008 at 7:38 PM, Rafael Trestini <tr...@gmail.com>
> wrote:
>> Petr,
>>
>> Yes, I'm using a maven project (created by archetype), in Eclipse
>> Ganymede. Commonly I use command line (im my case, on linux, but the
>> commands are equals both in windows and linux).
>>
>> Well, this may not be a root of your problem, but I will do a
>> step-by-step on how I created my projects. If you want, you can repeat
>> this steps, tunning to your needs;
>>
>> 1. Create a project with archetype:
>>
>>
>> On Tue, Nov 4, 2008 at 7:09 PM, Petr V. <gr...@yahoo.com>
> wrote:
>>> Thanks Rafael for the help.
>>>
>>> I created this project via maven commands on DOS.
>>>
>>> I imported then maven project in Eclipse.
>>>
>>> Now this maven project was not in build path so I believe I was
> getting error of not finding any junit test .
>>>
>>> Then  I clicked on project and select build path --> use as
source
> folder
>>>
>>> Now when I entered to Run menu, Run Configurations..., in left
site
> tree, selected JUnit,
>>> and my JUnitTest Case. I changed the runner for JUnit4, and the
test
> complains
>>> "java.lang.Exception  No runnable methods"
>>>
>>> Are you using maven project in Eclipse ? Did you set it in build
bath
> as source folder ?
>>>
>>> Thanks,
>>>
>>> Petr
>>>
>>> --- On Wed, 11/5/08, Rafael Trestini <tr...@gmail.com>
wrote:
>>> From: Rafael Trestini <tr...@gmail.com>
>>> Subject: Re: Can I run individual test in maven
>>> To: "Maven Users List" <us...@maven.apache.org>
>>> Date: Wednesday, November 5, 2008, 1:38 AM
>>>
>>> Petr,
>>>
>>> When I tried to reproduce your scenario, I got the message
"No
> JUnit
>>> test Found *for JUnit 3 runner*", because my set of tests was
> writen
>>> under junit 3.8.1. For this, I've entered in Run menu, Run
>>> Configurations..., in left site tree, selected JUnit, and my JUnit
>>> Test Case. Finally, I've changed the runner for JUnit4, and
the
> test
>>> works fine.
>>>
>>> Are you using maven eclipse plugin to generate your project?
>>>
>>> Rafael Trestini
>>>
>>> On Tue, Nov 4, 2008 at 6:06 PM, Petr V.
<gr...@yahoo.com>
> wrote:
>>>> Rafael,
>>>>
>>>> I am using Junit 4.5
>>>>
>>>> My test class is as follows
>>>>
>>>> import org.junit.Test;
>>>> import junit.framework.Assert;
>>>>
>>>> public class TestContract {
>>>>
>>>>     @Test
>>>>     public void testCom() throws Exception
>>>>     {
>>>>                         Assert.assertEquals(true, true);
>>>>
>>>>     }
>>>> }
>>>>
>>>> When I issue "mvn test" from command prompt it works
> fine. It
>>> even works
>>>> fine if I right click on component/module in eclipse and
choose
> mvn test
>>>> menu. But when I right click on test class in package explorer
and
> ask it
>>> to
>>>> run as junit test then  it says "No JUnit Tests
Found".
> Any idea
>>> what is
>>>> going on ?
>>>>
>>>> Thanks,
>>>>
>>>> Petr
>>>>
>>>> --- On Wed, 11/5/08, Rafael Trestini
<tr...@gmail.com>
> wrote:
>>>>
>>>> From: Rafael Trestini <tr...@gmail.com>
>>>> Subject: Re: Can I run individual test in maven
>>>> To: "Maven Users List"
<us...@maven.apache.org>,
>>> greatman787@yahoo.com
>>>> Date: Wednesday, November 5, 2008, 12:06 AM
>>>>
>>>> Petr,
>>>>
>>>> Please, let me know: are you using junit to code your test
cases?
> If
>>>> yes, eclipse has a "native" plugin to deal with
junit -
> no maven
>>> or
>>>> m2eclipse is needed. Is just to open your test case, Run As,
JUnit
>>>> Test Case.
>>>>
>>>> When 'mvn test' is running, it means that all test
cases
> will be
>>>> executed, to ensure that the package is not "broken"
due
> to
>>> logical
>>>> errors.
>>>>
>>>> Rafael Trestini
>>>>
>>>> On Tue, Nov 4, 2008 at 4:49 PM, Petr V.
>>>>  <gr...@yahoo.com> wrote:
>>>>> When I issue "mvn test" command, all my tests in
> test
>>> directory
>>>> are executed, what if I need to run some particular
test(assuming
> we have
>>>> different test classes instead of one big test class). And is
it
> possible
>>> in
>>>> eclipse to run one particular test with m2eclipse ?
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Petr
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Responsibility is the price of freedom
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Responsibility is the price of freedom
>>>
>>>
---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>> --
>> Responsibility is the price of freedom
>>
>
>
>
> --
> Responsibility is the price of freedom
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
>
>
>



-- 
Responsibility is the price of freedom

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




      

Re: Can I run individual test in maven

Posted by Rafael Trestini <tr...@gmail.com>.
Petr,

Well, is a very strange behavior. If I put "@Test" annotation above
"testApp()" method, it runs on eclipse fine.

Please check the following:
- junit 4.X is in your eclipse build path? (an easy way to see is
looking in "Referenced Library")
- Forget unit test created by maven. It is just a skeleton. Try to
create your own test case, by clicking with right button on
src/test/main, new Junit Test Case. On top of screen select "Junit 4",
and try to run it.

Just a note:
>>  We do not want to extend TestCase because we want to use jdk1.5 and its annotations.
You shall to know that extends TestCase and using jdk1.5 is not mutual
exclusive, ok? But I understand you ;-)

Rafael

On Tue, Nov 4, 2008 at 9:06 PM, Petr V. <gr...@yahoo.com> wrote:
> Hi Rafael,
>
> I guess I now know the issue. The test case generated by maven for a project can be run in Eclipse because it extends TestCase class
>
> But if you run following test in eclipse, the eclipse will complain "No Runnable Methods"  I am using TestRunner Junit 4 and I have junit 4.5 har in my build path as well. We do not want to extend TestCase because we want to use jdk1.5 and its annotations.
>
> import org.junit.Test;
>
> public class AppTest
> {
>
>     public void testApp()
>     {
>         assertTrue( true );
>     }
> }
>
> Can you please copy the above test in your maven project test directory and see if it could be run in eclipse.
>
> Thanks,
>
> Petr
>
> --- On Wed, 11/5/08, Rafael Trestini <tr...@gmail.com> wrote:
> From: Rafael Trestini <tr...@gmail.com>
> Subject: Re: Can I run individual test in maven
> To: "Maven Users List" <us...@maven.apache.org>
> Date: Wednesday, November 5, 2008, 2:45 AM
>
> Sorry.. I pressed "send" out of time...
>
> 1. Create a project with archetype:
>   $ mvn archetype:generate
>   // answer the question and archetype will create a skeleton of a
> project for you, with all default parameters
> 2. Put all your java code into /src/main/java
> 3. Put all your non-java code, like configurations, etc, in /src/main/resources
> 4. Create your junit tests in /src/test/java
> 5. If you need extra configuration for tests, use /src/test/resources for it
> 6. In pom.xml, change version of dependency with junit to 4.5
> 7. type:
>   $ mvn eclipse:eclipse
> 8. Import your project in eclipse
> 9. Try to run test now.
>
> Rafael Trestini
>
> On Tue, Nov 4, 2008 at 7:38 PM, Rafael Trestini <tr...@gmail.com>
> wrote:
>> Petr,
>>
>> Yes, I'm using a maven project (created by archetype), in Eclipse
>> Ganymede. Commonly I use command line (im my case, on linux, but the
>> commands are equals both in windows and linux).
>>
>> Well, this may not be a root of your problem, but I will do a
>> step-by-step on how I created my projects. If you want, you can repeat
>> this steps, tunning to your needs;
>>
>> 1. Create a project with archetype:
>>
>>
>> On Tue, Nov 4, 2008 at 7:09 PM, Petr V. <gr...@yahoo.com>
> wrote:
>>> Thanks Rafael for the help.
>>>
>>> I created this project via maven commands on DOS.
>>>
>>> I imported then maven project in Eclipse.
>>>
>>> Now this maven project was not in build path so I believe I was
> getting error of not finding any junit test .
>>>
>>> Then  I clicked on project and select build path --> use as source
> folder
>>>
>>> Now when I entered to Run menu, Run Configurations..., in left site
> tree, selected JUnit,
>>> and my JUnitTest Case. I changed the runner for JUnit4, and the test
> complains
>>> "java.lang.Exception  No runnable methods"
>>>
>>> Are you using maven project in Eclipse ? Did you set it in build bath
> as source folder ?
>>>
>>> Thanks,
>>>
>>> Petr
>>>
>>> --- On Wed, 11/5/08, Rafael Trestini <tr...@gmail.com> wrote:
>>> From: Rafael Trestini <tr...@gmail.com>
>>> Subject: Re: Can I run individual test in maven
>>> To: "Maven Users List" <us...@maven.apache.org>
>>> Date: Wednesday, November 5, 2008, 1:38 AM
>>>
>>> Petr,
>>>
>>> When I tried to reproduce your scenario, I got the message "No
> JUnit
>>> test Found *for JUnit 3 runner*", because my set of tests was
> writen
>>> under junit 3.8.1. For this, I've entered in Run menu, Run
>>> Configurations..., in left site tree, selected JUnit, and my JUnit
>>> Test Case. Finally, I've changed the runner for JUnit4, and the
> test
>>> works fine.
>>>
>>> Are you using maven eclipse plugin to generate your project?
>>>
>>> Rafael Trestini
>>>
>>> On Tue, Nov 4, 2008 at 6:06 PM, Petr V. <gr...@yahoo.com>
> wrote:
>>>> Rafael,
>>>>
>>>> I am using Junit 4.5
>>>>
>>>> My test class is as follows
>>>>
>>>> import org.junit.Test;
>>>> import junit.framework.Assert;
>>>>
>>>> public class TestContract {
>>>>
>>>>     @Test
>>>>     public void testCom() throws Exception
>>>>     {
>>>>                         Assert.assertEquals(true, true);
>>>>
>>>>     }
>>>> }
>>>>
>>>> When I issue "mvn test" from command prompt it works
> fine. It
>>> even works
>>>> fine if I right click on component/module in eclipse and choose
> mvn test
>>>> menu. But when I right click on test class in package explorer and
> ask it
>>> to
>>>> run as junit test then  it says "No JUnit Tests Found".
> Any idea
>>> what is
>>>> going on ?
>>>>
>>>> Thanks,
>>>>
>>>> Petr
>>>>
>>>> --- On Wed, 11/5/08, Rafael Trestini <tr...@gmail.com>
> wrote:
>>>>
>>>> From: Rafael Trestini <tr...@gmail.com>
>>>> Subject: Re: Can I run individual test in maven
>>>> To: "Maven Users List" <us...@maven.apache.org>,
>>> greatman787@yahoo.com
>>>> Date: Wednesday, November 5, 2008, 12:06 AM
>>>>
>>>> Petr,
>>>>
>>>> Please, let me know: are you using junit to code your test cases?
> If
>>>> yes, eclipse has a "native" plugin to deal with junit -
> no maven
>>> or
>>>> m2eclipse is needed. Is just to open your test case, Run As, JUnit
>>>> Test Case.
>>>>
>>>> When 'mvn test' is running, it means that all test cases
> will be
>>>> executed, to ensure that the package is not "broken" due
> to
>>> logical
>>>> errors.
>>>>
>>>> Rafael Trestini
>>>>
>>>> On Tue, Nov 4, 2008 at 4:49 PM, Petr V.
>>>>  <gr...@yahoo.com> wrote:
>>>>> When I issue "mvn test" command, all my tests in
> test
>>> directory
>>>> are executed, what if I need to run some particular test(assuming
> we have
>>>> different test classes instead of one big test class). And is it
> possible
>>> in
>>>> eclipse to run one particular test with m2eclipse ?
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Petr
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Responsibility is the price of freedom
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Responsibility is the price of freedom
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>> --
>> Responsibility is the price of freedom
>>
>
>
>
> --
> Responsibility is the price of freedom
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
>
>
>



-- 
Responsibility is the price of freedom

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


Re: Can I run individual test in maven

Posted by "Petr V." <gr...@yahoo.com>.
Hi Rafael,

I guess I now know the issue. The test case generated by maven for a project can be run in Eclipse because it extends TestCase class

But if you run following test in eclipse, the eclipse will complain "No Runnable Methods"  I am using TestRunner Junit 4 and I have junit 4.5 har in my build path as well. We do not want to extend TestCase because we want to use jdk1.5 and its annotations.

import org.junit.Test;

public class AppTest 
{
   
    public void testApp()
    {
        assertTrue( true );
    }
}

Can you please copy the above test in your maven project test directory and see if it could be run in eclipse.

Thanks,

Petr

--- On Wed, 11/5/08, Rafael Trestini <tr...@gmail.com> wrote:
From: Rafael Trestini <tr...@gmail.com>
Subject: Re: Can I run individual test in maven
To: "Maven Users List" <us...@maven.apache.org>
Date: Wednesday, November 5, 2008, 2:45 AM

Sorry.. I pressed "send" out of time...

1. Create a project with archetype:
   $ mvn archetype:generate
   // answer the question and archetype will create a skeleton of a
project for you, with all default parameters
2. Put all your java code into /src/main/java
3. Put all your non-java code, like configurations, etc, in /src/main/resources
4. Create your junit tests in /src/test/java
5. If you need extra configuration for tests, use /src/test/resources for it
6. In pom.xml, change version of dependency with junit to 4.5
7. type:
   $ mvn eclipse:eclipse
8. Import your project in eclipse
9. Try to run test now.

Rafael Trestini

On Tue, Nov 4, 2008 at 7:38 PM, Rafael Trestini <tr...@gmail.com>
wrote:
> Petr,
>
> Yes, I'm using a maven project (created by archetype), in Eclipse
> Ganymede. Commonly I use command line (im my case, on linux, but the
> commands are equals both in windows and linux).
>
> Well, this may not be a root of your problem, but I will do a
> step-by-step on how I created my projects. If you want, you can repeat
> this steps, tunning to your needs;
>
> 1. Create a project with archetype:
>
>
> On Tue, Nov 4, 2008 at 7:09 PM, Petr V. <gr...@yahoo.com>
wrote:
>> Thanks Rafael for the help.
>>
>> I created this project via maven commands on DOS.
>>
>> I imported then maven project in Eclipse.
>>
>> Now this maven project was not in build path so I believe I was
getting error of not finding any junit test .
>>
>> Then  I clicked on project and select build path --> use as source
folder
>>
>> Now when I entered to Run menu, Run Configurations..., in left site
tree, selected JUnit,
>> and my JUnitTest Case. I changed the runner for JUnit4, and the test
complains
>> "java.lang.Exception  No runnable methods"
>>
>> Are you using maven project in Eclipse ? Did you set it in build bath
as source folder ?
>>
>> Thanks,
>>
>> Petr
>>
>> --- On Wed, 11/5/08, Rafael Trestini <tr...@gmail.com> wrote:
>> From: Rafael Trestini <tr...@gmail.com>
>> Subject: Re: Can I run individual test in maven
>> To: "Maven Users List" <us...@maven.apache.org>
>> Date: Wednesday, November 5, 2008, 1:38 AM
>>
>> Petr,
>>
>> When I tried to reproduce your scenario, I got the message "No
JUnit
>> test Found *for JUnit 3 runner*", because my set of tests was
writen
>> under junit 3.8.1. For this, I've entered in Run menu, Run
>> Configurations..., in left site tree, selected JUnit, and my JUnit
>> Test Case. Finally, I've changed the runner for JUnit4, and the
test
>> works fine.
>>
>> Are you using maven eclipse plugin to generate your project?
>>
>> Rafael Trestini
>>
>> On Tue, Nov 4, 2008 at 6:06 PM, Petr V. <gr...@yahoo.com>
wrote:
>>> Rafael,
>>>
>>> I am using Junit 4.5
>>>
>>> My test class is as follows
>>>
>>> import org.junit.Test;
>>> import junit.framework.Assert;
>>>
>>> public class TestContract {
>>>
>>>     @Test
>>>     public void testCom() throws Exception
>>>     {
>>>                         Assert.assertEquals(true, true);
>>>
>>>     }
>>> }
>>>
>>> When I issue "mvn test" from command prompt it works
fine. It
>> even works
>>> fine if I right click on component/module in eclipse and choose
mvn test
>>> menu. But when I right click on test class in package explorer and
ask it
>> to
>>> run as junit test then  it says "No JUnit Tests Found".
Any idea
>> what is
>>> going on ?
>>>
>>> Thanks,
>>>
>>> Petr
>>>
>>> --- On Wed, 11/5/08, Rafael Trestini <tr...@gmail.com>
wrote:
>>>
>>> From: Rafael Trestini <tr...@gmail.com>
>>> Subject: Re: Can I run individual test in maven
>>> To: "Maven Users List" <us...@maven.apache.org>,
>> greatman787@yahoo.com
>>> Date: Wednesday, November 5, 2008, 12:06 AM
>>>
>>> Petr,
>>>
>>> Please, let me know: are you using junit to code your test cases?
If
>>> yes, eclipse has a "native" plugin to deal with junit -
no maven
>> or
>>> m2eclipse is needed. Is just to open your test case, Run As, JUnit
>>> Test Case.
>>>
>>> When 'mvn test' is running, it means that all test cases
will be
>>> executed, to ensure that the package is not "broken" due
to
>> logical
>>> errors.
>>>
>>> Rafael Trestini
>>>
>>> On Tue, Nov 4, 2008 at 4:49 PM, Petr V.
>>>  <gr...@yahoo.com> wrote:
>>>> When I issue "mvn test" command, all my tests in
test
>> directory
>>> are executed, what if I need to run some particular test(assuming
we have
>>> different test classes instead of one big test class). And is it
possible
>> in
>>> eclipse to run one particular test with m2eclipse ?
>>>>
>>>> Thanks,
>>>>
>>>> Petr
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Responsibility is the price of freedom
>>>
>>>
>>
>>
>>
>> --
>> Responsibility is the price of freedom
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>>
>>
>>
>
>
>
> --
> Responsibility is the price of freedom
>



-- 
Responsibility is the price of freedom

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




      

Re: Can I run individual test in maven

Posted by Rafael Trestini <tr...@gmail.com>.
Sorry.. I pressed "send" out of time...

1. Create a project with archetype:
   $ mvn archetype:generate
   // answer the question and archetype will create a skeleton of a
project for you, with all default parameters
2. Put all your java code into /src/main/java
3. Put all your non-java code, like configurations, etc, in /src/main/resources
4. Create your junit tests in /src/test/java
5. If you need extra configuration for tests, use /src/test/resources for it
6. In pom.xml, change version of dependency with junit to 4.5
7. type:
   $ mvn eclipse:eclipse
8. Import your project in eclipse
9. Try to run test now.

Rafael Trestini

On Tue, Nov 4, 2008 at 7:38 PM, Rafael Trestini <tr...@gmail.com> wrote:
> Petr,
>
> Yes, I'm using a maven project (created by archetype), in Eclipse
> Ganymede. Commonly I use command line (im my case, on linux, but the
> commands are equals both in windows and linux).
>
> Well, this may not be a root of your problem, but I will do a
> step-by-step on how I created my projects. If you want, you can repeat
> this steps, tunning to your needs;
>
> 1. Create a project with archetype:
>
>
> On Tue, Nov 4, 2008 at 7:09 PM, Petr V. <gr...@yahoo.com> wrote:
>> Thanks Rafael for the help.
>>
>> I created this project via maven commands on DOS.
>>
>> I imported then maven project in Eclipse.
>>
>> Now this maven project was not in build path so I believe I was getting error of not finding any junit test .
>>
>> Then  I clicked on project and select build path --> use as source folder
>>
>> Now when I entered to Run menu, Run Configurations..., in left site tree, selected JUnit,
>> and my JUnitTest Case. I changed the runner for JUnit4, and the test complains
>> "java.lang.Exception  No runnable methods"
>>
>> Are you using maven project in Eclipse ? Did you set it in build bath as source folder ?
>>
>> Thanks,
>>
>> Petr
>>
>> --- On Wed, 11/5/08, Rafael Trestini <tr...@gmail.com> wrote:
>> From: Rafael Trestini <tr...@gmail.com>
>> Subject: Re: Can I run individual test in maven
>> To: "Maven Users List" <us...@maven.apache.org>
>> Date: Wednesday, November 5, 2008, 1:38 AM
>>
>> Petr,
>>
>> When I tried to reproduce your scenario, I got the message "No JUnit
>> test Found *for JUnit 3 runner*", because my set of tests was writen
>> under junit 3.8.1. For this, I've entered in Run menu, Run
>> Configurations..., in left site tree, selected JUnit, and my JUnit
>> Test Case. Finally, I've changed the runner for JUnit4, and the test
>> works fine.
>>
>> Are you using maven eclipse plugin to generate your project?
>>
>> Rafael Trestini
>>
>> On Tue, Nov 4, 2008 at 6:06 PM, Petr V. <gr...@yahoo.com> wrote:
>>> Rafael,
>>>
>>> I am using Junit 4.5
>>>
>>> My test class is as follows
>>>
>>> import org.junit.Test;
>>> import junit.framework.Assert;
>>>
>>> public class TestContract {
>>>
>>>     @Test
>>>     public void testCom() throws Exception
>>>     {
>>>                         Assert.assertEquals(true, true);
>>>
>>>     }
>>> }
>>>
>>> When I issue "mvn test" from command prompt it works fine. It
>> even works
>>> fine if I right click on component/module in eclipse and choose mvn test
>>> menu. But when I right click on test class in package explorer and ask it
>> to
>>> run as junit test then  it says "No JUnit Tests Found". Any idea
>> what is
>>> going on ?
>>>
>>> Thanks,
>>>
>>> Petr
>>>
>>> --- On Wed, 11/5/08, Rafael Trestini <tr...@gmail.com> wrote:
>>>
>>> From: Rafael Trestini <tr...@gmail.com>
>>> Subject: Re: Can I run individual test in maven
>>> To: "Maven Users List" <us...@maven.apache.org>,
>> greatman787@yahoo.com
>>> Date: Wednesday, November 5, 2008, 12:06 AM
>>>
>>> Petr,
>>>
>>> Please, let me know: are you using junit to code your test cases? If
>>> yes, eclipse has a "native" plugin to deal with junit - no maven
>> or
>>> m2eclipse is needed. Is just to open your test case, Run As, JUnit
>>> Test Case.
>>>
>>> When 'mvn test' is running, it means that all test cases will be
>>> executed, to ensure that the package is not "broken" due to
>> logical
>>> errors.
>>>
>>> Rafael Trestini
>>>
>>> On Tue, Nov 4, 2008 at 4:49 PM, Petr V.
>>>  <gr...@yahoo.com> wrote:
>>>> When I issue "mvn test" command, all my tests in test
>> directory
>>> are executed, what if I need to run some particular test(assuming we have
>>> different test classes instead of one big test class). And is it possible
>> in
>>> eclipse to run one particular test with m2eclipse ?
>>>>
>>>> Thanks,
>>>>
>>>> Petr
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Responsibility is the price of freedom
>>>
>>>
>>
>>
>>
>> --
>> Responsibility is the price of freedom
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>>
>>
>>
>
>
>
> --
> Responsibility is the price of freedom
>



-- 
Responsibility is the price of freedom

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


Re: Can I run individual test in maven

Posted by Rafael Trestini <tr...@gmail.com>.
Petr,

Yes, I'm using a maven project (created by archetype), in Eclipse
Ganymede. Commonly I use command line (im my case, on linux, but the
commands are equals both in windows and linux).

Well, this may not be a root of your problem, but I will do a
step-by-step on how I created my projects. If you want, you can repeat
this steps, tunning to your needs;

1. Create a project with archetype:


On Tue, Nov 4, 2008 at 7:09 PM, Petr V. <gr...@yahoo.com> wrote:
> Thanks Rafael for the help.
>
> I created this project via maven commands on DOS.
>
> I imported then maven project in Eclipse.
>
> Now this maven project was not in build path so I believe I was getting error of not finding any junit test .
>
> Then  I clicked on project and select build path --> use as source folder
>
> Now when I entered to Run menu, Run Configurations..., in left site tree, selected JUnit,
> and my JUnitTest Case. I changed the runner for JUnit4, and the test complains
> "java.lang.Exception  No runnable methods"
>
> Are you using maven project in Eclipse ? Did you set it in build bath as source folder ?
>
> Thanks,
>
> Petr
>
> --- On Wed, 11/5/08, Rafael Trestini <tr...@gmail.com> wrote:
> From: Rafael Trestini <tr...@gmail.com>
> Subject: Re: Can I run individual test in maven
> To: "Maven Users List" <us...@maven.apache.org>
> Date: Wednesday, November 5, 2008, 1:38 AM
>
> Petr,
>
> When I tried to reproduce your scenario, I got the message "No JUnit
> test Found *for JUnit 3 runner*", because my set of tests was writen
> under junit 3.8.1. For this, I've entered in Run menu, Run
> Configurations..., in left site tree, selected JUnit, and my JUnit
> Test Case. Finally, I've changed the runner for JUnit4, and the test
> works fine.
>
> Are you using maven eclipse plugin to generate your project?
>
> Rafael Trestini
>
> On Tue, Nov 4, 2008 at 6:06 PM, Petr V. <gr...@yahoo.com> wrote:
>> Rafael,
>>
>> I am using Junit 4.5
>>
>> My test class is as follows
>>
>> import org.junit.Test;
>> import junit.framework.Assert;
>>
>> public class TestContract {
>>
>>     @Test
>>     public void testCom() throws Exception
>>     {
>>                         Assert.assertEquals(true, true);
>>
>>     }
>> }
>>
>> When I issue "mvn test" from command prompt it works fine. It
> even works
>> fine if I right click on component/module in eclipse and choose mvn test
>> menu. But when I right click on test class in package explorer and ask it
> to
>> run as junit test then  it says "No JUnit Tests Found". Any idea
> what is
>> going on ?
>>
>> Thanks,
>>
>> Petr
>>
>> --- On Wed, 11/5/08, Rafael Trestini <tr...@gmail.com> wrote:
>>
>> From: Rafael Trestini <tr...@gmail.com>
>> Subject: Re: Can I run individual test in maven
>> To: "Maven Users List" <us...@maven.apache.org>,
> greatman787@yahoo.com
>> Date: Wednesday, November 5, 2008, 12:06 AM
>>
>> Petr,
>>
>> Please, let me know: are you using junit to code your test cases? If
>> yes, eclipse has a "native" plugin to deal with junit - no maven
> or
>> m2eclipse is needed. Is just to open your test case, Run As, JUnit
>> Test Case.
>>
>> When 'mvn test' is running, it means that all test cases will be
>> executed, to ensure that the package is not "broken" due to
> logical
>> errors.
>>
>> Rafael Trestini
>>
>> On Tue, Nov 4, 2008 at 4:49 PM, Petr V.
>>  <gr...@yahoo.com> wrote:
>>> When I issue "mvn test" command, all my tests in test
> directory
>> are executed, what if I need to run some particular test(assuming we have
>> different test classes instead of one big test class). And is it possible
> in
>> eclipse to run one particular test with m2eclipse ?
>>>
>>> Thanks,
>>>
>>> Petr
>>>
>>>
>>>
>>>
>>
>>
>>
>> --
>> Responsibility is the price of freedom
>>
>>
>
>
>
> --
> Responsibility is the price of freedom
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
>
>
>



-- 
Responsibility is the price of freedom

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


Re: Can I run individual test in maven

Posted by "Petr V." <gr...@yahoo.com>.
Thanks Rafael for the help.

I created this project via maven commands on DOS.

I imported then maven project in Eclipse.

Now this maven project was not in build path so I believe I was getting error of not finding any junit test . 

Then  I clicked on project and select build path --> use as source folder

Now when I entered to Run menu, Run Configurations..., in left site tree, selected JUnit, 
and my JUnitTest Case. I changed the runner for JUnit4, and the test complains 
"java.lang.Exception  No runnable methods"

Are you using maven project in Eclipse ? Did you set it in build bath as source folder ?

Thanks,

Petr

--- On Wed, 11/5/08, Rafael Trestini <tr...@gmail.com> wrote:
From: Rafael Trestini <tr...@gmail.com>
Subject: Re: Can I run individual test in maven
To: "Maven Users List" <us...@maven.apache.org>
Date: Wednesday, November 5, 2008, 1:38 AM

Petr,

When I tried to reproduce your scenario, I got the message "No JUnit
test Found *for JUnit 3 runner*", because my set of tests was writen
under junit 3.8.1. For this, I've entered in Run menu, Run
Configurations..., in left site tree, selected JUnit, and my JUnit
Test Case. Finally, I've changed the runner for JUnit4, and the test
works fine.

Are you using maven eclipse plugin to generate your project?

Rafael Trestini

On Tue, Nov 4, 2008 at 6:06 PM, Petr V. <gr...@yahoo.com> wrote:
> Rafael,
>
> I am using Junit 4.5
>
> My test class is as follows
>
> import org.junit.Test;
> import junit.framework.Assert;
>
> public class TestContract {
>
>     @Test
>     public void testCom() throws Exception
>     {
>                         Assert.assertEquals(true, true);
>
>     }
> }
>
> When I issue "mvn test" from command prompt it works fine. It
even works
> fine if I right click on component/module in eclipse and choose mvn test
> menu. But when I right click on test class in package explorer and ask it
to
> run as junit test then  it says "No JUnit Tests Found". Any idea
what is
> going on ?
>
> Thanks,
>
> Petr
>
> --- On Wed, 11/5/08, Rafael Trestini <tr...@gmail.com> wrote:
>
> From: Rafael Trestini <tr...@gmail.com>
> Subject: Re: Can I run individual test in maven
> To: "Maven Users List" <us...@maven.apache.org>,
greatman787@yahoo.com
> Date: Wednesday, November 5, 2008, 12:06 AM
>
> Petr,
>
> Please, let me know: are you using junit to code your test cases? If
> yes, eclipse has a "native" plugin to deal with junit - no maven
or
> m2eclipse is needed. Is just to open your test case, Run As, JUnit
> Test Case.
>
> When 'mvn test' is running, it means that all test cases will be
> executed, to ensure that the package is not "broken" due to
logical
> errors.
>
> Rafael Trestini
>
> On Tue, Nov 4, 2008 at 4:49 PM, Petr V.
>  <gr...@yahoo.com> wrote:
>> When I issue "mvn test" command, all my tests in test
directory
> are executed, what if I need to run some particular test(assuming we have
> different test classes instead of one big test class). And is it possible
in
> eclipse to run one particular test with m2eclipse ?
>>
>> Thanks,
>>
>> Petr
>>
>>
>>
>>
>
>
>
> --
> Responsibility is the price of freedom
>
>



-- 
Responsibility is the price of freedom

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




      

Re: Can I run individual test in maven

Posted by Rafael Trestini <tr...@gmail.com>.
Petr,

When I tried to reproduce your scenario, I got the message "No JUnit
test Found *for JUnit 3 runner*", because my set of tests was writen
under junit 3.8.1. For this, I've entered in Run menu, Run
Configurations..., in left site tree, selected JUnit, and my JUnit
Test Case. Finally, I've changed the runner for JUnit4, and the test
works fine.

Are you using maven eclipse plugin to generate your project?

Rafael Trestini

On Tue, Nov 4, 2008 at 6:06 PM, Petr V. <gr...@yahoo.com> wrote:
> Rafael,
>
> I am using Junit 4.5
>
> My test class is as follows
>
> import org.junit.Test;
> import junit.framework.Assert;
>
> public class TestContract {
>
>     @Test
>     public void testCom() throws Exception
>     {
>                         Assert.assertEquals(true, true);
>
>     }
> }
>
> When I issue "mvn test" from command prompt it works fine. It even works
> fine if I right click on component/module in eclipse and choose mvn test
> menu. But when I right click on test class in package explorer and ask it to
> run as junit test then  it says "No JUnit Tests Found". Any idea what is
> going on ?
>
> Thanks,
>
> Petr
>
> --- On Wed, 11/5/08, Rafael Trestini <tr...@gmail.com> wrote:
>
> From: Rafael Trestini <tr...@gmail.com>
> Subject: Re: Can I run individual test in maven
> To: "Maven Users List" <us...@maven.apache.org>, greatman787@yahoo.com
> Date: Wednesday, November 5, 2008, 12:06 AM
>
> Petr,
>
> Please, let me know: are you using junit to code your test cases? If
> yes, eclipse has a "native" plugin to deal with junit - no maven or
> m2eclipse is needed. Is just to open your test case, Run As, JUnit
> Test Case.
>
> When 'mvn test' is running, it means that all test cases will be
> executed, to ensure that the package is not "broken" due to logical
> errors.
>
> Rafael Trestini
>
> On Tue, Nov 4, 2008 at 4:49 PM, Petr V.
>  <gr...@yahoo.com> wrote:
>> When I issue "mvn test" command, all my tests in test directory
> are executed, what if I need to run some particular test(assuming we have
> different test classes instead of one big test class). And is it possible in
> eclipse to run one particular test with m2eclipse ?
>>
>> Thanks,
>>
>> Petr
>>
>>
>>
>>
>
>
>
> --
> Responsibility is the price of freedom
>
>



-- 
Responsibility is the price of freedom

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


Re: Can I run individual test in maven

Posted by "David C. Hicks" <dh...@i-hicks.org>.
You can run a single test in Maven like this:

    mvn -Dtest=MyTestClass test

Note that you must specify the name of the TestCase class.


Rafael Trestini wrote:
> Petr,
>
> Please, let me know: are you using junit to code your test cases? If
> yes, eclipse has a "native" plugin to deal with junit - no maven or
> m2eclipse is needed. Is just to open your test case, Run As, JUnit
> Test Case.
>
> When 'mvn test' is running, it means that all test cases will be
> executed, to ensure that the package is not "broken" due to logical
> errors.
>
> Rafael Trestini
>
> On Tue, Nov 4, 2008 at 4:49 PM, Petr V. <gr...@yahoo.com> wrote:
>   
>> When I issue "mvn test" command, all my tests in test directory are executed, what if I need to run some particular test(assuming we have different test classes instead of one big test class). And is it possible in eclipse to run one particular test with m2eclipse ?
>>
>> Thanks,
>>
>> Petr
>>
>>
>>
>>
>>     
>
>
>
>   

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


Re: Can I run individual test in maven

Posted by "Petr V." <gr...@yahoo.com>.
Rafael,

I am using Junit 4.5

My test class is as follows

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

public class TestContract {

    @Test
    public void testCom() throws Exception
    {                        
                        Assert.assertEquals(true, true);                        
    }
}
    
When
I issue "mvn test" from command prompt it works fine. It even works
fine if I right click on component/module in eclipse and choose mvn
test menu. But when I right click on test class in package explorer and
ask it to run as junit test then  it says "No JUnit Tests Found". Any
idea what is going on ?

Thanks,

Petr

--- On Wed, 11/5/08, Rafael Trestini <tr...@gmail.com> wrote:
From: Rafael Trestini <tr...@gmail.com>
Subject: Re: Can I run individual test in maven
To: "Maven Users List" <us...@maven.apache.org>, greatman787@yahoo.com
Date: Wednesday, November 5, 2008, 12:06 AM

Petr,

Please, let me know: are you using junit to code your test cases? If
yes, eclipse has a "native" plugin to deal with junit - no maven or
m2eclipse is needed. Is just to open your test case, Run As, JUnit
Test Case.

When 'mvn test' is running, it means that all test cases will be
executed, to ensure that the package is not "broken" due to logical
errors.

Rafael Trestini

On Tue, Nov 4, 2008 at 4:49 PM, Petr V. <gr...@yahoo.com> wrote:
> When I issue "mvn test" command, all my tests in test directory
are executed, what if I need to run some particular test(assuming we have
different test classes instead of one big test class). And is it possible in
eclipse to run one particular test with m2eclipse ?
>
> Thanks,
>
> Petr
>
>
>
>



-- 
Responsibility is the price of freedom



      

Re: Can I run individual test in maven

Posted by Rafael Trestini <tr...@gmail.com>.
Petr,

Please, let me know: are you using junit to code your test cases? If
yes, eclipse has a "native" plugin to deal with junit - no maven or
m2eclipse is needed. Is just to open your test case, Run As, JUnit
Test Case.

When 'mvn test' is running, it means that all test cases will be
executed, to ensure that the package is not "broken" due to logical
errors.

Rafael Trestini

On Tue, Nov 4, 2008 at 4:49 PM, Petr V. <gr...@yahoo.com> wrote:
> When I issue "mvn test" command, all my tests in test directory are executed, what if I need to run some particular test(assuming we have different test classes instead of one big test class). And is it possible in eclipse to run one particular test with m2eclipse ?
>
> Thanks,
>
> Petr
>
>
>
>



-- 
Responsibility is the price of freedom

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