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 7538015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:00:11+00:00 2026-05-30T07:00:11+00:00

This is a question for JUnit in general, but it involves browser automation with

  • 0

This is a question for JUnit in general, but it involves browser automation with Selenium WebDriver.

I have a JUnit4 TestSuite that runs one JUnit test class. My JUnit test class has 10 test methods in it that fill out a webpage. In this JUnit test class I have a List object that holds data for tests. I can currently drive the Unit test by accessing List object like so:

// all data for my tests can be grabbed using the get(0) method
testListObject.getPersonEntity.get(0).getName();

My question for StackOverflow users is:

How do I refactor my JUnit test so that it will run through multiple tests in my Object list?

In other words:

  1. Is it possible to create a method that loops through the list and somehow gets all the test methods to fire off each time in the loop? Would this make sense? Then the unit test wouldn’t be finished each time it fills out a page, but instead only after it fills out the page for every test case in the list.

  2. Or, should I move the test list out to the TestSuite object and somehow call the Unit test class multiple times? If so, how?

I am unsure how to accomplish this, not being very familiar with how JUnit works. In other words, not knowing the underpinnings of how the “test” methods get fired off, I don’t currently know the proper way to get a JUnit test to run multiple times. Another way to ask: how would I get the TestSuite class to call the unit test class multiple times, each time with a different testentity argument (from a List) that drives the test?

  • 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-30T07:00:13+00:00Added an answer on May 30, 2026 at 7:00 am

    See Parameterized and Parameters in JUnit. I think they provide what you need. For a little more help, see this past SO link. You just need to use @RunWith(Parameterized.class), provide a method annotated with Parameterized.Parameters that returns the data needed for each run (in a List, array or some collection), and the weirdest thing is providing a constructor for the test class that takes the input type of your iterable data.

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

Sidebar

Related Questions

Edit: Not JUnit 4 available at this time. Hi there, I have a question
I have this build.xml file http://gist.github.com/315109 . Every task runs smoothly, but test .
This question was very helpful, however I have a list control in my report,
I know this is silly question, but i am just stuck with this: 1.I
I saw this question: Repeating code in JUnit tests earlier today. How do you
I apologize if this question was asked already before but I could not find
I have a basic question: When using JUnit, in your test suite (the class
This is quite similar question to one older but the solution did not work
This is more of a design question. Suppose you have a method like this
This is a very basic question for JUnit testing. I wrote a program which

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.