Return-Path: Delivered-To: apmail-maven-users-archive@www.apache.org Received: (qmail 67158 invoked from network); 17 Sep 2008 20:33:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Sep 2008 20:33:40 -0000 Received: (qmail 47126 invoked by uid 500); 17 Sep 2008 20:33:28 -0000 Delivered-To: apmail-maven-users-archive@maven.apache.org Received: (qmail 47078 invoked by uid 500); 17 Sep 2008 20:33:28 -0000 Mailing-List: contact users-help@maven.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Maven Users List" Reply-To: "Maven Users List" Delivered-To: mailing list users@maven.apache.org Received: (qmail 47067 invoked by uid 99); 17 Sep 2008 20:33:28 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Sep 2008 13:33:28 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ryan@ijws.com designates 142.46.57.114 as permitted sender) Received: from [142.46.57.114] (HELO ns2.ijws.com) (142.46.57.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Sep 2008 20:32:28 +0000 Received: from cpe001839a5a2dd-cm000f9f7b7c5c.cpe.net.cable.rogers.com ([72.140.243.94] helo=[192.168.100.104]) by ns2.ijws.com with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1Kg3hr-00061u-P1 for users@maven.apache.org; Wed, 17 Sep 2008 16:33:00 -0400 Message-ID: <48D1699A.9070102@ijws.com> Date: Wed, 17 Sep 2008 16:33:30 -0400 From: Ryan de Laplante User-Agent: Thunderbird 2.0.0.14 (X11/20080505) MIME-Version: 1.0 To: Maven Users List Subject: Re: Unable to use Junit 4 annotations References: <48D1593E.6000907@ijws.com> <48D16132.9040405@ijws.com> In-Reply-To: <48D16132.9040405@ijws.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org It turns out I have to tell Spring that it is using JUnit 4 by annotating my class: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations={"file:src/test/resources/META-INF/applicationContext.xml"}) public class SettingsDAOTest extends AbstractJpaTests { Before the AbstractJpaTests superclass set everything up and injected what I needed into my test class. Now all of that is gone, so I had to add the @ContextConfiguration annotation and @Autorwired to inject the DAO. Now it doesn't recognize the entity I am trying to merge with JPA. I also found out that @RunWith(SpringJUnit4ClassRunner.class) only works with Junit 4.4 and newer. But, surefire maven2 plugin causes trouble when using Junit 4.5 so you have to downgrade to 4.4: http://jira.springframework.org/browse/SPR-5145 Too much trouble. I'm going to use JUnit 3 style configs for this class so that AbstractJpaTest actually works. Ryan Ryan de Laplante wrote: > Actually, it must be using JUnit 4 because I have a test suite > completely configured with annotations. Also, when one of my unit > tests throws an untrapped exception I see this in the stack tract: > > java.lang.NullPointerException > at > > ... notice Spring Framework is doing something. My test class extends > AbstractJpaTestCase > > at java.lang.reflect.Method.invoke(Method.java:597) > at junit.framework.TestCase.runTest(TestCase.java:164) > at junit.framework.TestCase.runBare(TestCase.java:130) > at > org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76) > > at > org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.access$001(AbstractAnnotationAwareTransactionalTests.java:71) > > > ... Notice surefire Junit4TestSet > > at > org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62) > > at > org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140) > > at > > > So this must be a spring problem. > > > Thanks, > Ryan > > > Ryan de Laplante wrote: >> Hi, >> >> My junit tests work if I prefix test method names with the word >> test. If I don't do that and rely on the @Test annotation then the >> test methods are not executed. >> >> I have this in my POM: >> >> >> junit >> junit >> 4.5 >> test >> >> >> and in my build section I have: >> >> >> >> maven-compiler-plugin >> 2.0.2 >> >> 1.5 >> 1.5 >> >> >> >> maven-surefire-plugin >> 2.4.3 >> >> >> >> **/*TestSuite.java >> >> >> >> >> >> So I am using the latest version of surefire. Any ideas why it's not >> using Junit 4? >> >> Thanks, >> Ryan --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@maven.apache.org For additional commands, e-mail: users-help@maven.apache.org