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_tests_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#a12265586
Sent from the Maven - Users mailing list archive at Nabble.com.


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

Reply via email to