dependsOnMethods and abstract methods/classes

classic Classic list List threaded Threaded
27 messages Options
12
Reply | Threaded
Open this post in threaded view
|

dependsOnMethods and abstract methods/classes

tarun3kumar

Hello,

public abstract class CoordinatesTest {
    @Test(dependsOnMethods = {"createCoordinates"})
    public void implementsCharSequence() {
        assertTrue(createCoordinates() instanceof CharSequence);
    }

    @Test
    public abstract Coordinates createCoordinates();
}

After inheritance and implementing the abtract method the result is an exception:
CoordinatesTest.implementsCharSequence() is depending on nonexistent method CoordinatesTest.createCoordinates

How can I avoid this? Is it a bug or a feature?

Thank you
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=55013&messageID=109903#109903


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: dependsOnMethods and abstract methods/classes

Alexandru Popescu ☀

Hmmm.... nice one. Gonna check it and get back to you. Are you running
a testclass or are you using a suite definition file?

./alex
--
.w( the_mindstorm )p.
  TestNG co-founder
EclipseTestNG Creator


On 12/23/06, Matthias Berndt <[hidden email]> wrote:

>
> Hello,
>
> public abstract class CoordinatesTest {
>     @Test(dependsOnMethods = {"createCoordinates"})
>     public void implementsCharSequence() {
>         assertTrue(createCoordinates() instanceof CharSequence);
>     }
>
>     @Test
>     public abstract Coordinates createCoordinates();
> }
>
> After inheritance and implementing the abtract method the result is an exception:
> CoordinatesTest.implementsCharSequence() is depending on nonexistent method CoordinatesTest.createCoordinates
>
> How can I avoid this? Is it a bug or a feature?
>
> Thank you
> ---------------------------------------------------------------------
> Posted via Jive Forums
> http://forums.opensymphony.com/thread.jspa?threadID=55013&messageID=109903#109903
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: dependsOnMethods and abstract methods/classes

tarun3kumar

> Are you running a testclass or are you using a suite definition file?

I'm running it from a definition file. Does it matter?
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=55013&messageID=109922#109922


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: dependsOnMethods and abstract methods/classes

Alexandru Popescu ☀

On 12/23/06, Matthias Berndt <[hidden email]> wrote:
>
> > Are you running a testclass or are you using a suite definition file?
>
> I'm running it from a definition file. Does it matter?
>

Nope, but I want to reproduce the problem :-). The suite definition
should not include the abstract class, cause otherwise TestNG will try
to run it .

./alex
--
.w( the_mindstorm )p.
  TestNG co-founder
EclipseTestNG Creator

 ---------------------------------------------------------------------
> Posted via Jive Forums
> http://forums.opensymphony.com/thread.jspa?threadID=55013&messageID=109922#109922
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: dependsOnMethods and abstract methods/classes

Alexandru Popescu ☀

On 12/23/06, Alexandru Popescu <[hidden email]> wrote:

> On 12/23/06, Matthias Berndt <[hidden email]> wrote:
> >
> > > Are you running a testclass or are you using a suite definition file?
> >
> > I'm running it from a definition file. Does it matter?
> >
>
> Nope, but I want to reproduce the problem :-). The suite definition
> should not include the abstract class, cause otherwise TestNG will try
> to run it .
>

I couldn't reproduce the problem, so I am suspecting that you suite
definition file contains also the abstract class, and so TestNG is
trying to run it.

./alex
--
.w( the_mindstorm )p.
  TestNG co-founder
EclipseTestNG Creator

> ./alex
> --
> .w( the_mindstorm )p.
>   TestNG co-founder
> EclipseTestNG Creator
>
>  ---------------------------------------------------------------------
> > Posted via Jive Forums
> > http://forums.opensymphony.com/thread.jspa?threadID=55013&messageID=109922#109922
> >
> >
> > > >
> >
>

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: dependsOnMethods and abstract methods/classes

tarun3kumar
In reply to this post by Alexandru Popescu ☀

> The suite definition should not include the abstract class, cause otherwise TestNG will try > to run it .

How and why does TestNG initialize and run abstract classes? For me it doesn't make much sense.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=55013&messageID=109935#109935


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: dependsOnMethods and abstract methods/classes

Hani Suleiman

Matthias Berndt said:
>
>> The suite definition should not include the abstract class, cause
>> otherwise TestNG will try > to run it .
>
> How and why does TestNG initialize and run abstract classes? For me it
> doesn't make much sense.

I agree, even abstract classes are listed, tng should know what to do with
them (or not do, in this case!)



--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: dependsOnMethods and abstract methods/classes

Alexandru Popescu ☀
In reply to this post by tarun3kumar

On 12/23/06, Matthias Berndt <[hidden email]> wrote:
>
> > The suite definition should not include the abstract class, cause otherwise TestNG will try > to run it .
>
> How

As you already noticed it doesn't :-)

>and why does TestNG initialize and run abstract classes? For me it
doesn't make much sense.
>

Because you told it so, by including that class in the list you are
passing to TestNG.

But,  I agree that we may need to check this before trying to
instantiate an abstract test.

./alex
--
.w( the_mindstorm )p.
  TestNG co-founder
EclipseTestNG Creator

---------------------------------------------------------------------
> Posted via Jive Forums
> http://forums.opensymphony.com/thread.jspa?threadID=55013&messageID=109935#109935
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: dependsOnMethods and abstract methods/classes

Cédric Beust ♔
In reply to this post by tarun3kumar


On 12/23/06, Matthias Berndt <[hidden email]> wrote:

> The suite definition should not include the abstract class, cause otherwise TestNG will try > to run it .

How and why does TestNG initialize and run abstract classes? For me it doesn't make much sense.

It's never a good idea to include a base class in your testng.xml.  Consider:

Base:
  @Test
  public void b() {}

A extends Base:
  @Test
  public void a() {}

If you put both Base and A in your testng.xml, TestNG will run a(), b() and b().

I can't think of a scenario where that's what you would want...

--
Cédric
--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: dependsOnMethods and abstract methods/classes

Hani Suleiman

>
> It's never a good idea to include a base class in your testng.xml.
> Consider:
>
> Base:
>   @Test
>   public void b() {}
>
> A extends Base:
>   @Test
>   public void a() {}
>
> If you put both Base and A in your testng.xml, TestNG will run a(), b()
> and
> b().
>
How about if the base class just included configuration methods? Should
you include it then or will tng automatically walk up A's heirarchy to
discover them? I remember having issues with that previously (where I had
to include the base class), though that was a while ago.


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: dependsOnMethods and abstract methods/classes

Cédric Beust ♔


On 12/23/06, Hani Suleiman <[hidden email]> wrote:

>
> It's never a good idea to include a base class in your testng.xml.
> Consider:
>
> Base:
>   @Test
>   public void b() {}
>
> A extends Base:
>   @Test
>   public void a() {}
>
> If you put both Base and A in your testng.xml, TestNG will run a(), b()
> and
> b().
>
How about if the base class just included configuration methods? Should
you include it then or will tng automatically walk up A's heirarchy to
discover them? I remember having issues with that previously (where I had
to include the base class), though that was a while ago.

TestNG will see these methods on the child classes automatically, there is no need to put the base class in your testng.xml file.

--
Cédric
--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: dependsOnMethods and abstract methods/classes

tarun3kumar
I have attached a archive to clarify what I want to do.

In short words to have a testmethod and an abstract factorymethod in an abstract class. After inheritance and implemeting the abstract factorymethod i want to run the testmethod in the baseclass.

Why should I want to do this? Because I want to write tests for interfaces and abstract business logic classes.

It doesn't matter if you run the suite or the testclass directly.

output:
===
[RunInfo] Adding method selector: org.testng.internal.XmlMethodSelector@1edc073 priority: 10
[TestClass] Creating TestClass for [ClassImpl B]
[TestClass] Adding method A.testObject() on TestClass class B

===============================================
unknown
Total tests run: 0, Failures: 0, Skips: 0
===============================================

org.testng.TestNGException:
A.testObject() is depending on nonexistent method A.createObject
        at org.testng.internal.MethodHelper.findMethodsNamed(MethodHelper.java:155)
        at org.testng.internal.MethodHelper.topologicalSort(MethodHelper.java:393)
        at org.testng.internal.MethodHelper.sortMethods(MethodHelper.java:467)
        at org.testng.internal.MethodHelper.collectAndOrderMethods(MethodHelper.java:72)
        at org.testng.internal.MethodHelper.collectAndOrderMethods(MethodHelper.java:40)
        at org.testng.TestRunner.initMethods(TestRunner.java:339)
        at org.testng.TestRunner.init(TestRunner.java:205)
        at org.testng.TestRunner.init(TestRunner.java:177)
        at org.testng.TestRunner.<init>(TestRunner.java:122)
        at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRunner.java:385)
        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:199)
        at org.testng.SuiteRunner.run(SuiteRunner.java:148)
        at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:901)
        at org.testng.TestNG.runSuitesLocally(TestNG.java:863)
        at org.testng.TestNG.run(TestNG.java:613)
        at org.testng.TestNG.privateMain(TestNG.java:1001)
        at org.testng.TestNG.main(TestNG.java:938)
===

PS: If anyone knows a good or better pattern to test interfaces and abstract methods ... let me know.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=55013&messageID=109949#109949

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---


demo.tar.gz (750 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: dependsOnMethods and abstract methods/classes

Cédric Beust ♔
I see what's going on, and this has nothing to do with the abstract keyword:  you are depending on a method that doesn't have a @Test annotation. 

Adding @Test to your createObject() method will fix the problem, but it will also mark that method as a test method, so TestNG will invoke it (and it will ignore the returned value).  So you'll end up with two invocations of that method.

Why not simply invoke createObject() directly in your test method?

--
Cedric

On 12/23/06, Matthias Berndt <[hidden email]> wrote:
I have attached a archive to clarify what I want to do.

In short words to have a testmethod and an abstract factorymethod in an abstract class. After inheritance and implemeting the abstract factorymethod i want to run the testmethod in the baseclass.

Why should I want to do this? Because I want to write tests for interfaces and abstract business logic classes.

It doesn't matter if you run the suite or the testclass directly.

output:
===
[RunInfo] Adding method selector: org.testng.internal.XmlMethodSelector@1edc073 priority: 10
[TestClass] Creating TestClass for [ClassImpl B]
[TestClass] Adding method A.testObject() on TestClass class B

===============================================
unknown
Total tests run: 0, Failures: 0, Skips: 0
===============================================

org.testng.TestNGException:
A.testObject() is depending on nonexistent method A.createObject
        at org.testng.internal.MethodHelper.findMethodsNamed(MethodHelper.java:155)
        at org.testng.internal.MethodHelper.topologicalSort (MethodHelper.java:393)
        at org.testng.internal.MethodHelper.sortMethods(MethodHelper.java:467)
        at org.testng.internal.MethodHelper.collectAndOrderMethods(MethodHelper.java:72)
        at org.testng.internal.MethodHelper.collectAndOrderMethods (MethodHelper.java:40)
        at org.testng.TestRunner.initMethods(TestRunner.java:339)
        at org.testng.TestRunner.init(TestRunner.java:205)
        at org.testng.TestRunner.init(TestRunner.java:177)
        at org.testng.TestRunner.<init>(TestRunner.java:122)
        at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRunner.java:385)
        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:199)
        at org.testng.SuiteRunner.run(SuiteRunner.java:148)
        at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:901)
        at org.testng.TestNG.runSuitesLocally(TestNG.java:863)
        at org.testng.TestNG.run (TestNG.java:613)
        at org.testng.TestNG.privateMain(TestNG.java:1001)
        at org.testng.TestNG.main(TestNG.java:938)
===

PS: If anyone knows a good or better pattern to test interfaces and abstract methods ... let me know.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=55013&messageID=109949#109949


--
Cédric
--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: dependsOnMethods and abstract methods/classes

tarun3kumar
> Adding @Test to your createObject() method will fix the problem.

It works, thanks.

> Why not simply invoke createObject() directly in your test method?

Sorry, I can't understand you. what do you mean with "invoke directly"? What could be more directly than calling the method?

There is still a problem. I added some groups to the tests and I'll get the same error.

The attached file includes the groups.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=55013&messageID=109952#109952

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---


demo.tar.gz (804 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: dependsOnMethods and abstract methods/classes

Cédric Beust ♔


On 12/23/06, Matthias Berndt <[hidden email]> wrote:
> Adding @Test to your createObject() method will fix the problem.

It works, thanks.

Ok but keep in mind that this method is now invoked twice:  by TestNG and by yourself when you need to create an object.

> Why not simply invoke createObject() directly in your test method?

Sorry, I can't understand you. what do you mean with "invoke directly"? What could be more directly than calling the method?

Yes, you are already doing that, that's why I don't see the point in declaring that you depend on that method on top of already invoking it explicitly...


--
Cédric
--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: dependsOnMethods and abstract methods/classes

Mark Derricutt
In reply to this post by Cédric Beust ♔
On 12/24/06, C�dric Beust <[hidden email]> wrote:

It's never a good idea to include a base class in your testng.xml.  Consider:

The flaw here I see (potentially) is not that you might put the <class/> in the suite.xml file, but if you use a <package/> that includes the abstract class.

You've not explicitly told TestNG to use it - only to use all -valid- test classes in that package.

(I havn't tested this, so I'm not sure if TestNG ignores abstract classes picked up by a package selector or not...)

--
http://www.talios.com
http://www.flickr.com/photos/talios
--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: dependsOnMethods and abstract methods/classes

Alexandru Popescu ☀
On 12/23/06, Mark Derricutt <[hidden email]> wrote:

> On 12/24/06, C dric Beust <[hidden email]> wrote:
> >
> > It's never a good idea to include a base class in your testng.xml.
> Consider:
> >
>
> The flaw here I see (potentially) is not that you might put the <class/> in
> the suite.xml file, but if you use a <package/> that includes the abstract
> class.
>
> You've not explicitly told TestNG to use it - only to use all -valid- test
> classes in that package.
>
> (I havn't tested this, so I'm not sure if TestNG ignores abstract classes
> picked up by a package selector or not...)
>

I was thinking about the same thing... and I cannot remember a place
where we are checking this.  And I believe we should exclude them by
default even if specified by <class> or <package>.

./alex
--
.w( the_mindstorm )p.
  TestNG co-founder
EclipseTestNG Creator


> --
> http://www.talios.com
> http://www.flickr.com/photos/talios
>
>  >
>

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: dependsOnMethods and abstract methods/classes

Alexandru Popescu ☀
On 12/23/06, Alexandru Popescu <[hidden email]> wrote:

> On 12/23/06, Mark Derricutt <[hidden email]> wrote:
> > On 12/24/06, C dric Beust <[hidden email]> wrote:
> > >
> > > It's never a good idea to include a base class in your testng.xml.
> > Consider:
> > >
> >
> > The flaw here I see (potentially) is not that you might put the <class/> in
> > the suite.xml file, but if you use a <package/> that includes the abstract
> > class.
> >
> > You've not explicitly told TestNG to use it - only to use all -valid- test
> > classes in that package.
> >
> > (I havn't tested this, so I'm not sure if TestNG ignores abstract classes
> > picked up by a package selector or not...)
> >
>
> I was thinking about the same thing... and I cannot remember a place
> where we are checking this.  And I believe we should exclude them by
> default even if specified by <class> or <package>.
>

In fact I was wrong: here it is from the TestNGClassFinder:

[code]
        if ((null == thisInstance) && Modifier.isAbstract(cls.getModifiers())) {
          Utils.log("", 2, "[WARN] Found an abstract class with no
valid instance attached: " + cls);
          continue;
        }
[/code]

so we are already doing the right thing.

./alex
--
.w( the_mindstorm )p.
  TestNG co-founder
EclipseTestNG Creator

> ./alex
> --
> .w( the_mindstorm )p.
>   TestNG co-founder
> EclipseTestNG Creator
>
>
> > --
> > http://www.talios.com
> > http://www.flickr.com/photos/talios
> >
> >  > >
> >
>

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: dependsOnMethods and abstract methods/classes

tarun3kumar
In reply to this post by Cédric Beust ♔

> Ok but keep in mind that this method is now invoked twice

Thanks for bringing this to my mind. The code is more or less a finger exercise.

But why does the addition group definition break the testsuite?
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=55013&messageID=109979#109979


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: dependsOnMethods and abstract methods/classes

Alexandru Popescu ☀

On 12/24/06, Matthias Berndt <[hidden email]> wrote:
>
> > Ok but keep in mind that this method is now invoked twice
>
> Thanks for bringing this to my mind. The code is more or less a finger exercise.
>
> But why does the addition group definition break the testsuite?

I am not sure what is broken. I have run the test using the following
sources (applied the changed suggested previously):

[code]
@Test(groups = { "all", "abstract" })
public abstract class A {
        public abstract Object createObject();

        @Test(groups = { "unknown" })
        public void testObject() {
                assertTrue(createObject() instanceof Object);
        }
}

@Test(groups = { "all" })
public class B extends A {
        @Override
        public Object createObject() {
                return new Object();
        }
}
[/code]

and I get:

[code]
===============================================
unknown
Total tests run: 2, Failures: 0, Skips: 0
===============================================
[/code]

Please notice that due to the fact that B has a type level annotation
createObject() is still a @Test method. Same continues to be true if
you remove the annotation as it is available on the super type.

./alex
--
.w( the_mindstorm )p.
  TestNG co-founder
EclipseTestNG Creator

> ---------------------------------------------------------------------
> Posted via Jive Forums
> http://forums.opensymphony.com/thread.jspa?threadID=55013&messageID=109979#109979
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

12