This is probably something the junit guys would be able to help you
with more than we can. Unless of course they say it is strictly a
Maven/Surefire issue...
Wayne
On 8/22/07, flyingtiger <[EMAIL PROTECTED]> wrote:
>
> I don't think there's a way to exclude the Wrapper since it is an inner
> class. I tried to exclude it but it won't work. I then added a fake test so
> the Wrapper class turns to be
>
> 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();
> }
> public void testTrue(){
> assertTrue(true);
> }
> }
>
> but now I've got complier error
>
> junit.framework.AssertionFailedError: Exception in constructor: testTrue
> (java.l
> ang.Error: Unresolved compilation problem:
> Implicit super constructor TestSetup() is undefined. Must explicitly
> inv
> oke another constructor
>
> the TestSetup class only has one constructor public
> TestSetup(junit.framework.Test test)
>
>
>
>
> Nathaniel Stoddard wrote:
> >
> > I think what you want to do is add the Wrapper class to your list of
> > excluded files.
> >
> > <exclude>**/Wrapper</exclude>
> >
> > .... or something like that. The static inner class is throwing me off,
> > but you get the idea. At this point, surefire is instantiating it just
> > fine, but can't find any testXXX methods, so fails the test. If Wrapper
> > is going to be extended by actual test cases elsewhere, it's never going
> > to be used itself, ergo the exclude.
> >
> > flyingtiger wrote:
> >> 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: [email protected]
> >>> 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]
> >>>
> >>>
> >>>
> >>>
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > 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#a12278173
> 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]