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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:51:12+00:00 2026-05-25T19:51:12+00:00

For my assignment, I have to develop several jUnit tests for the method: addAll(int

  • 0

For my assignment, I have to develop several jUnit tests for the method:

 addAll(int index, Collection c)

This method is part of the class ArrayList – built in to java.

I figured out how to create the tests and run them in Eclipse IDE, but I’m a little confused as to exactly how I’m supposed to develop the tests. Could I get an example that includes what I should have in a @before, @beforeClass, @after, @test method?

To make this clear, I understand the format of the methods…I just don’t understand HOW to test this method.

http://download.oracle.com/javase/1.4.2/docs/api/java/util/ArrayList.html#addAll(java.util.Collection)

  • 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-25T19:51:12+00:00Added an answer on May 25, 2026 at 7:51 pm

    So, what you need to test is that the method inserts all the elements in the passed Collection and that it inserts them into the appropriate position in the ArrayList.

    Think of all the possible senerios and test each one.

    1. start with empty arraylist
    2. pass empty collection
    3. use index of 0
    4. use index > 0
    5. etc, etc…

    After the add, verify / assert that the ArrayList now has all the elements that it should have in the correct order / locations.

    Also test the error cases with @Test(expected=…).

    1. index < 0
    2. index > arrayList.size()
    3. null collection
    4. come up with other ideas

    Also… assertThat in combination with Hamcrest’s IsIterableContainingInOrder would be helpful for verification.

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

Sidebar

Related Questions

(this is indirectly a part of a much larger homework assignment) I have something
I have an assignment in a language-independent class, and part of it is using
Greetings All; I have to develop a C++ class library comprising a collection of
So this is a small part of a large assignment I have, I'm just
For a database assignment I have to model a system for a school. Part
I have got a assignment to develop a IPhone application in HTML 5 &
I have an assignment and i got a library including an interface class. [InfoItem]
This is a practice assignment where I have to create a table space with
Acttualy this is my assignment.I have three-four file,related by student record.Every file have two-three
What's a clear way of doing this? For a school assignment I have to

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.