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

  • Home
  • SEARCH
  • 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 6562431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:42:29+00:00 2026-05-25T13:42:29+00:00

I am playing around with a new web service and thought at the same

  • 0

I am playing around with a new web service and thought at the same time that I was writing some proof of concept code I would practice writing them as unit tests. So I wrote a test class that authenticates and then looks at the result (a session object) to see if the authentication was successful. That test is its own class and there are a couple other authentication methods that it tests. That works just fine. But now if I want to actually use that session object later in other test classes what is the best practice way of doing this.

I guess I could make the session object a singleton on the authentication test class. Then pull it from there. I could re-authenticate each time. Even with both of those I want to be sure the authentication test has run each time. I did fine the @AfterClass annotation in the testng docs but that does not apply to classes. I think its to be used only one methods to make them run after the rest of the tests in the class have run. I cant think of a good way to do this that does not feel like a little hack. What approach would the more experienced testng users suggest?

  • Thanks
  • 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-25T13:42:30+00:00Added an answer on May 25, 2026 at 1:42 pm

    If you’re using the same class, simply store the token in a field.

    If you are using different classes, use ITestContext#{getAttribute,setAttribute} to share data among your tests (here is how to do that).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to ruby and I'm playing around with the IRB. I found that
I'm playing around with a native (non-web) single-player game I'm writing, and it occured
I'm pretty new to the Spring Framework, I've been playing around with it and
I'm playing around with the <canvas> element, drawing lines and such. I've noticed that
I was playing around with my own Sudoku solver and was looking for some
EDIT: I am using Code Igniter: www.codeigniter.com So I'm new to web developement and
Just playing around with the now released Silverlight 2.0. I'm trying to put a
While playing around with regexps in Scala I wrote something like this: scala> val
I'm currently playing around with HTML_QuickForm for generating forms in PHP. It seems kind
I'm playing around with LinqToSQL using an existing multi-lingual database, but I'm running into

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.