Other than ensuring, as Wayne said, that your compiling correctly, not much. 
This class worked fine for me under Junit 4.5:

package test;

import static org.junit.Assert.*;

import java.util.ArrayList;

import org.junit.Test;

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

    @Test(expected = IndexOutOfBoundsException.class)
    public void testOutOfBounds() {
        new ArrayList<Object>().get(1);
    }

    @Test
    public void app() {
        assertTrue(true);
    }

    @Test(expected = IndexOutOfBoundsException.class)
    public void outOfBounds() {
        new ArrayList<Object>().get(1);
    }
}

 

-----Original Message-----
From: Petr V. [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 29, 2008 4:38 PM
To: Maven Users List
Subject: Re: Maven + Junit 4.5 dependency does not work

I removed extends TestCase but same result, it did not help.

Actually annotations are completely ignored. I put the @Test in front of test 
but function name did not start with prefix "test" and it was not executed at 
all. 

I thought if you put the annotation @Test then you don't need to prefix your 
test function with "test". Some thing is really going bad ..

Any more pointers ?

Thanks,

Petr


--- On Thu, 10/30/08, Edelson, Justin <[EMAIL PROTECTED]> wrote:
From: Edelson, Justin <[EMAIL PROTECTED]>
Subject: Re: Maven + Junit 4.5 dependency does not work
To: [email protected]
Date: Thursday, October 30, 2008, 1:26 AM

I could be wrong about this, but I think with JUnit 4, you can either extend 
TestCase or use annotations, but not both. Try removing 'extends TestCase'

Justin 

----- Original Message -----
From: Petr V. <[EMAIL PROTECTED]>
To: [email protected] <[email protected]>
Sent: Wed Oct 29 16:14:54 2008
Subject: Maven + Junit 4.5 dependency does not work 

I must be doing some thing very silly :-(

I have this very simple test in maven project test directory. I have dependency 
on junit-4.5 and junit-util-4.5 in my pom file


import java.io.IOException;
import java.util.ArrayList;

import org.junit.Test;
import junit.framework.TestCase;

public class AppTest extends TestCase
{
   
    @Test
    public void testApp()
    {
        assertTrue( true );
    }
    
    @Test(expected=IndexOutOfBoundsException.class)
     public void testOutOfBounds() {
        new ArrayList<Object>().get(1);
     }
  
}

When I issue maven package command then my tests fail saying

Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.063 sec <<< 
FAILURE!
testOutOfBounds(com.xx.AppTest)  Time elapsed: 0 sec  <<< ERROR!
java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
    at java.util.ArrayList.RangeCheck(ArrayList.java:547)
    at java.util.ArrayList.get(ArrayList.java:322)
    at com.xx.AppTest.testOutOfBounds(AppTest.java:45)

I have asked via annotation that I am expecting exception but it is not caught, 
why this is happening ? it simply ignores the following line of code
[EMAIL PROTECTED](expected=IndexOutOfBoundsException.class)

Any idea what am I doing wrong, I am sure it is one of those silly things which 
make you cry :-(

Thanks,

Petr  



      



      

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to