I changed the inner class to public static class Wrapper extends TestSetup { public Wrapper(){ ; } public Wrapper(Test arg0) { super(arg0); // TODO Auto-generated constructor stub } public Wrapper(TestSuite suite){ super(suite); } public void setUp() throws Exception { prepareTestData(); } public void tearDown() throws Exception { destroyTestData(); } }
eclipse is complaining an error "Implicit super constructor TestSetup() is undefined. Must explicitly invoke another constructor". runing it I got Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.062 sec <<< FA ILURE! warning(junit.framework.TestSuite$1) Time elapsed: 0 sec <<< FAILURE! junit.framework.AssertionFailedError: No tests found in com.gorillanation.dartai p.TestDataAccess$Wrapper at junit.framework.Assert.fail(Assert.java:47)... and what do you mean by surefire has different version? can I modify my pom.xml to specify the version of the surefire? I did a read the surefire plug in page but didn't really find such an option. my pom: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <excludes> <exclude>**/AppTest.*</exclude> </excludes> <useFile>false</useFile> </configuration> </plugin> Bryan Loofbourrow wrote: > >>> with mvn test I got error > "junit.framework.AssertionFailedError: Class Order$OrderChargeTest has > no > public constructor TestCase(String name) or TestCase()" << > > If memory serves, I think the solution is to make sure all your classes > (inner included) have a no-args constructor (or, as appropriate, a > constructor-with-String). I think surefire might be force-instantiating > all of the classes. I also seem to recall that only certain surefire > versions exhibit this behavior. > > -- Bryan > > -----Original Message----- > From: flyingtiger [mailto:[EMAIL PROTECTED] > Sent: Tuesday, August 21, 2007 4:59 PM > To: users@maven.apache.org > Subject: A unit test error with maven > > > I have a unit test that I want to run run setUp() and tearDown() code > once > for all of my tests. I use an inner class as a wrapper to do the job. it > worked fine with eclipse but with mvn test I got error > "junit.framework.AssertionFailedError: Class Order$OrderChargeTest has > no > public constructor TestCase(String name) or TestCase()" > > anybody as any idea? > > my code here: > > ... > > public class TestDataAccess extends TestCase { > private static final Logger logger = LoggerFinder.getLogger(); > protected static DataAccess dao = new DataAccess();; > > public TestDataAccess(String testName) { > super(testName); > // TODO Auto-generated constructor stub > } > > public static class Wrapper extends TestSetup { > public Wrapper(Test arg0) { > super(arg0); > // TODO Auto-generated constructor stub > } > public Wrapper(TestSuite suite){ > super(suite); > } > public void setUp() throws Exception { > prepareTestData(); > } > public void tearDown() throws Exception { > destroyTestData(); > } > } > > public static Test suite() { > TestSuite suite = new TestSuite(); > suite.addTest(new TestDataAccess("testGetAdvertiser")); > suite.addTest(new > TestDataAccess("testGetAdvertiserIdByDfpId")); > Wrapper wrapper = new Wrapper(suite); > return wrapper; > } > > public void testGetAdvertiser() throws Exception { > int id = 100000; > GorillaAdvertiser gAdvertiser = dao.getAdvertiser(id); > assertEquals(100000, gAdvertiser.getId()); > assertEquals("http://www.test.com", > gAdvertiser.getUrl()); > assertEquals("Test SF ID", > gAdvertiser.getSalesforceObjectId()); > assertEquals("Test Advertiser", gAdvertiser.getName()); > } > > public void testGetAdvertiserIdByDfpId() throws Exception { > int dfpId = 1397500; > String id = dao.getAdvertiserIdByDfpId(dfpId); > assertEquals("2", id); > } > > private static void prepareTestData() throws Exception { > logger.info("preparing data..."); > dao.establishConnections(); > prepareAdvertiser(); > } > > private static void destroyTestData() throws Exception { > logger.info("destroying data..."); > destroyAdvertiser(); > dao.closeConnections(); > } > > private static void prepareAdvertiser() throws Exception { > String sql = "insert into advertisers (id, name, url, > dfp_id, > salesforce_object_id) " > + "values (100000, 'Test Advertiser', > 'http://www.test.com', 100000, > 'Test SF ID')"; > PreparedStatement ps = > dao.getAdOpsConn().prepareStatement(sql); > ps.executeUpdate(); > ps.close(); > dao.getAdOpsConn().commit(); > } > > private static void destroyAdvertiser() throws Exception { > String sql = "delete from advertisers where id = > 100000"; > PreparedStatement ps = > dao.getAdOpsConn().prepareStatement(sql); > ps.executeUpdate(); > ps.close(); > dao.getAdOpsConn().commit(); > } > > } > > error message: > Running com.gorillanation.dartaip.TestDataAccess$Wrapper > Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.031 > sec > <<< FA > ILURE! > warning(junit.framework.TestSuite$1) Time elapsed: 0 sec <<< FAILURE! > junit.framework.AssertionFailedError: Class > com.gorillanation.dartaip.TestDataAc > cess$Wrapper has no public constructor TestCase(String name) or > TestCase() > > I searched the internet found this > > http://www.oreillynet.com/onjava/blog/2004/12/where_should_your_unit_tes > ts_g.html > > I did exactly as suggested but didn't help. > > anybody any idea? > > > > -- > View this message in context: > http://www.nabble.com/A-unit-test-error-with-maven-tf4308575s177.html#a1 > 2265586 > Sent from the Maven - Users mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/A-unit-test-error-with-maven-tf4308575s177.html#a12266127 Sent from the Maven - Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]