Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Excluding inner test-classes
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Carsten  
View profile  
 More options Nov 2, 12:23 pm
From: Carsten <carsten.guberna...@googlemail.com>
Date: Mon, 2 Nov 2009 09:23:52 -0800 (PST)
Local: Mon, Nov 2 2009 12:23 pm
Subject: Excluding inner test-classes
Hi,

we use factory classes to generate sample test-cases, often with inner
classes.

TestNG seems not to like inner test-classes like

public class TestCaseFactory
{
  class MyTestClass
  {
    @Test
    public void testAll()
    {
    }
  }

  @Factory
  public Object[] createTestCases()
  {
    Object[] testCases = new Object[1];
    testCases[0] = new MyTestClass()          // create an inner class
- testng tries to execute this inner class
    {
    };
    return testCases;
  }

}

When executing the Factory class (which is not supposed to be a test
at all) i get the following error message:

java.lang.IllegalAccessException: Class
org.testng.internal.MethodHelper can not access a member of class
test.recommind.utility.TestCaseFactory$MyTestClass with modifiers
"public"
... Removed 20 stack frames

We still use testng 5.8 and i debugged into it. Filtering these inner
classes in ClassHelper solved the problem for us:
  public static <T> T tryOtherConstructor(Class<T> declaringClass)
{
      if (declaringClass.getModifiers() == 0)
      {
        return null;
      }
     // remaining code...

}

The class modifiers are defined here:
http://java.sun.com/docs/books/jvms/first_edition/html/ClassFile.doc....

I couldn't find modifier 0, but it applies to inner classes. Is it
possible to add the code fragment to TestNG? Then we do not have to
use custom testng-code.

Thanks,
Carsten


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cédric Beust ♔  
View profile  
 More options Nov 2, 12:41 pm
From: Cédric Beust ♔ <cbe...@google.com>
Date: Mon, 2 Nov 2009 09:41:26 -0800
Local: Mon, Nov 2 2009 12:41 pm
Subject: Re: [testng-users] Excluding inner test-classes

Hi Carsten,

This sounds reasonable, can you send me a diff of your patch?  I'll
incorporate it.

--
Cédric

On Mon, Nov 2, 2009 at 9:23 AM, Carsten
<carsten.guberna...@googlemail.com>wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Carsten  
View profile  
 More options Nov 2, 1:16 pm
From: Carsten <carsten.guberna...@googlemail.com>
Date: Mon, 2 Nov 2009 10:16:18 -0800 (PST)
Local: Mon, Nov 2 2009 1:16 pm
Subject: Re: Excluding inner test-classes
Hi Cedric,

I sent the diff file by email.

Thanks,
Carsten

On Nov 2, 6:41 pm, Cédric Beust ♔ <cbe...@google.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google