all classes handled as TestCase if name ends with Test

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

all classes handled as TestCase if name ends with Test

Marko Bauhardt-3
Hi all,
i have a curious junit test error.
for example: i have a normal class that extends from TestCase. This  
class has a inner interface with name ITest.


---
public class MY_TEST_CLASS extends TestCase {

     interface ITest {
         String testMethod();
     }

....

}
---

So in my build.gradle i have included all classes with suffix *Test

---
test {
   include '**/*Test.class'
}
---

if i execute this i get a testFailure that the class ITest has no  
public constructur. (but ITest is an interface and no class ;) )

---
  <testcase classname="junit.framework.TestSuite$1" name="warning"  
time="0.0050">
     <failure message="Class MY_TEST_CLASS$ITest has no public  
constructor TestCase(String name) or TestCase()"  
type
=
"junit
.framework.AssertionFailedError">junit.framework.AssertionFailedError:  
Class MY_TEST_CLASS$ITest has no public constructor TestCase(String  
name) or TestCase()
</failure>
   </testcase>
---

but anyway. i exclude this interface in the test task


---
test {
   include '**/*Test.class'
   exclude '**/*ITest*'
}
---

So i think also all Interfaces with suffix 'Test' are handled as  
TestCase. Also i have created a temporary class with name 'FooTest' in  
my testSrcFolder. This class do not extend from TestCase but this  
class is handled as TestCase and will be execute with junit.

Marko








---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: all classes handled as TestCase if name ends with Test

hans_d
Administrator
Hi Marko,

On Jul 3, 2008, at 10:04 AM, Marko Bauhardt wrote:

> Hi all,
> i have a curious junit test error.
> for example: i have a normal class that extends from TestCase. This  
> class has a inner interface with name ITest.
>
>
> ---
> public class MY_TEST_CLASS extends TestCase {
>
>     interface ITest {
>         String testMethod();
>     }
>
> ....
>
> }
> ---
>
> So in my build.gradle i have included all classes with suffix *Test
>
> ---
> test {
>   include '**/*Test.class'
> }
> ---
>
> if i execute this i get a testFailure that the class ITest has no  
> public constructur. (but ITest is an interface and no class ;) )

I guess this is a pecularity of the Ant JUnit task. The task  
perspective is to try to execute all classes as Unit tests that obey  
to the pattern, and throw an exception if it does not work. What  
exactly the Ant task is trying to do with the interface class I don't  
know. But excluding it is the way of dealing with this. The same  
would be necessary when executing the tests from an Ant script.

Thanks

- Hans

>
> ---
>  <testcase classname="junit.framework.TestSuite$1" name="warning"  
> time="0.0050">
>     <failure message="Class MY_TEST_CLASS$ITest has no public  
> constructor TestCase(String name) or TestCase()"  
> type="junit.framework.AssertionFailedError">junit.framework.AssertionF
> ailedError: Class MY_TEST_CLASS$ITest has no public constructor  
> TestCase(String name) or TestCase()
> </failure>
>   </testcase>
> ---
>
> but anyway. i exclude this interface in the test task
>
>
> ---
> test {
>   include '**/*Test.class'
>   exclude '**/*ITest*'
> }
> ---
>
> So i think also all Interfaces with suffix 'Test' are handled as  
> TestCase. Also i have created a temporary class with name 'FooTest'  
> in my testSrcFolder. This class do not extend from TestCase but  
> this class is handled as TestCase and will be execute with junit.
>
> Marko
>
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

--
Hans Dockter
Gradle Project lead
http://www.gradle.org





---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: all classes handled as TestCase if name ends with Test

Marko Bauhardt-3
> I guess this is a pecularity of the Ant JUnit task. The task  
> perspective is to try to execute all classes as Unit tests that obey  
> to the pattern, and throw an exception if it does not work. What  
> exactly the Ant task is trying to do with the interface class I  
> don't know. But excluding it is the way of dealing with this. The  
> same would be necessary when executing the tests from an Ant script.


ah ok. i understand. then i have to exclude those interfaces etc.  
explicit in the build file.

marko


>
>
> Thanks
>
> - Hans
>
>>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email