Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1039843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:09:01+00:00 2026-05-16T15:09:01+00:00

I’m learning to use TestNG for IntelliJ IDEA 9. As far as I understand,

  • 0

I’m learning to use TestNG for IntelliJ IDEA 9.

As far as I understand, One way to put a test in a group called name is to annotate it @Test(group = "name"). To run a method before each test, annotate it with @BeforeMethod.

In my test setup I want a method to run before each test only in a particular group. So there is a method beforeA that runs before each test in group A, a method beforeB running before each B test and so on.

Example code:

public class TestExample
{
    @BeforeMethod(groups = "A")
    public void beforeA()
    {
        System.out.println("before A");
    }

    @BeforeMethod(groups = "B")
    public void beforeB()
    {
        System.out.println("before B");
    }

    @Test(groups = "A")
    public void A1()
    {
        System.out.println("test A1");
    }

    @Test(groups = "A")
    public void A2()
    {
        System.out.println("test A2");
    }

    @Test(groups = "B")
    public void B1()
    {
        System.out.println("test B1");
    }

    @Test(groups = "B")
    public void B2()
    {
        System.out.println("test B2");
    }
}

I expect output like

before A
test A1
before A
test A2
before B
test B1
before B
test B2

but I get the following:

before A
before B
before A
before B
test A2
before A
before B
before A
before B
test B1

===============================================

test B2

===============================================
Custom suite
Total tests run: 4, Failures: 0, Skips: 0
===============================================

And IntelliJ IDEA has highlighted all my annotations with the message “Group A is undefined” or “Group B is undefined”.

What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:09:02+00:00Added an answer on May 16, 2026 at 3:09 pm
    1. The listing isn’t in good order, this is intelliJ’s fault. Run the test in command line or with maven the order will be correct.
    2. @BeforeMethod and @AfterMethod seem broken with groups.
    3. IntelliJ remember groups you used before, if you use a group that isn’t remembered yet, the message “Group X is undefined” will be shown. Just pres alt + Enter on an undefined group to remember it.

    Resources :

    • TestNG bug tracker – BeforeMethod and AfterMethod groups support broken
    • TestNG Mailing list – Order of execution for configuration methods involving groups
    • TestNG Mailing list – Before and After for groups
    • talios.com – New Inspections for the IntelliJ TestNG Plugin
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.