Class TestSuiteValuesCollection
Summary: The TestSuiteValuesCollection provides test on values collection methods.
It offer different type of test in differente case scanario, in order to test their correct behaviour.
The first section of this test suite contains the test in the TestCollection.java file
assigned by the Professor, correctly translated in the JUnit format.
Some tests of the TestCollection.java file were not included because they are already included
in the test cases ideated by me.
After this section there are several section for each method (or group of feature) contains
the test cases ideated by me.
Test Suite Design: This test suite contains fine-grained different test cases
for each method of the HCollection interface in order to individuate errors in HCollection methods
Test cases include inspection test, modification test and iterator test. In the test suite there are
many test cases focusing on limit and special cases,
invalid arguments and etc.
Each method is tested apart from others.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add()
Summary: add method test case.void
AddAll()
Summary: addAll method test case.static void
AfterClass JUnit static method.void
After JUnit method.void
Summary: backing clear and put test case.void
Summary: backing remove with iterator test case.void
Summary: backing putall and remove test case.void
Summary: backing put and remove test case.void
Summary: backing removeAll test case.void
Summary: baking retainAll test case.static void
BeforeClass JUnit static method.void
Before JUnit method.void
clear()
Summary: clear method test case.void
Summary: clear method test case.void
Summary: clear method test case.void
Summary: clear method test case.void
Summary: contains method test case.void
Summary: contains method test case.void
Summary: contains method test case.void
Summary: contains method test case.void
Summary: contains method test case.void
Summary: containsAll method test case.void
Summary: containsAll method test case.void
Summary: containsAll method test case.void
Summary: test metodo containsAll(Collection c) e verifico che gli elementi di c siano presenti in ctvoid
Summary: containsAll method test case.void
Summary: containsAll method test case.void
Summary: containsAll method test case.void
Equals_1()
Summary: equals method test case.void
Summary: equals method test case.void
equals_o()
Summary: test metodo equals(Object o) e controllo se sono ugualivoid
Summary: equals method test case.void
Summary: equals method test case.void
Summary: hashCode test case.void
is_empty()
Summary: isEmpty method test case.void
Summary: hasNext and next methods test case.void
Summary: hasNext and next methods test case.void
Summary:iterator next method test casevoid
Summary: remove method test case.void
Summary: remove method test case.void
Summary: removeAll method test case test removeAll(Collection c), rimuovo da ct tutti gli elementi di cvoid
Summary: remove method test case.void
Summary: remove method test case.void
Summary: remove method test case.void
Summary: remove method test case.void
remove_o()
Summary: remove method test case.void
Summary: remove method test case.void
Summary: remove method test case.void
Summary: removeAll method test case.void
Summary: removeAll method test case.void
Summary: removeAll method test case.void
Summary: removeAll method test case.void
Summary: removeAll method test case.void
Summary: removeAll method test case.void
Summary: retainAll method test case.void
Summary: retainAll method test case.void
Summary: retainAll method test case.void
Summary: retainAll method test case.void
Summary: retainAll method test case.void
Summary: retainAll method test case.void
size()
Summary: size method test case.void
Summary: size, isEmpty method test case.void
Summary: size, isEmpty method test case.void
Summary: size, isEmpty method test case.void
Summary: size, isEmpty method test case.void
to_array()
Summary: toArray method test case.void
Summary: toArray method test case.void
Summary: toArray test case.void
Summary: toArray(HCollection) method test case.void
Summary: toArray(HCollection) method test case.void
Summary: toArray method test case.void
Summary: toArray method test case.void
Summary: toString method test case.void
Summary: toString method test case.
-
Constructor Details
-
TestSuiteValuesCollection
public TestSuiteValuesCollection()
-
-
Method Details
-
beforeClassMethod
public static void beforeClassMethod()BeforeClass JUnit static method. Announces the the test begin and starts its timer. -
beforeMethod
public void beforeMethod()Before JUnit method. It initializes the map used in this suite. -
afterMethod
public void afterMethod()After JUnit method. It assigns null to m2. It was preferred to not call the clear method as it was target of some test cases, therefore after method cancels any reference to the previous pointed objects, then removed by the Garbage Collector. -
afterClassMethod
public static void afterClassMethod()AfterClass JUnit static method. Announces the the test end and stops its timer. Prints milliseconds elapsed from the beginning. -
contains_o
public void contains_o()Summary: contains method test case. verifico che coll1 contenga l' elemento
Test Case Design: Test contains method with one value
Test Description: Simply call
Pre-Condition: coll1 contiene l'elemento da verificare
Post-Condition: ris e' true
Expected Results: coll1 conteiene l'elemento, contains return true
-
to_array
public void to_array()Summary: toArray method test case. verifico che temp contenga gli elementi di head
Test Case Design: Tests toArray with a single element.
Test Description: La variabile booleana size è vera se leght è 1, content è vera se temp[0] equals "Collection Adapter".
Pre-Condition: head con almeno un elemento
Post-Condition: temp che e' un array contenete gli elementi di head
Expected Results: size is 1 and the array contains the correct elements so size AND content are true
-
to_array_a
public void to_array_a()Summary: toArray method test case. verifico che head contenga gli elementi di head, facendo il confronto con il suo contenuto
Test Case Design: Tests toArray with a single element.
Test Description: La variabile booleana content è vera se temp[0] equals "Collection Adapter".
Pre-Condition: head con almeno un elemento, a array di destinazione
Post-Condition: a contiene gli elementi di head
Expected Results: the array contains the correct elements so content is true
-
remove_o
public void remove_o()Summary: remove method test case.
Test Case Design: test remove(Object o), rimuovo da ct l'elemento o e verifico che la dimensione di ct sia cambiata
Test Description: o is removed from ct
Pre-Condition: ct con almeno un elemento
Post-Condition: ct senza l'elemento o
Expected Results: ris is true
-
remove_all_c
public void remove_all_c()Summary: removeAll method test case test removeAll(Collection c), rimuovo da ct tutti gli elementi di c
Test Case Design: tests removeAll method on a collection, should return true
Test Description: o is removed from ct
Pre-Condition: ct con almeno un elemento
Post-Condition: ct senza gli elementi di Collection c
Expected Results: ris is true
-
retain_all_c
public void retain_all_c()Summary: retainAll method test case. modifica ct facendogli contenere alla fine solo gli elementi presenti anche in c
Test Case Design: Tests remove method on a collection, which should return true.
Test Description: o is removed from ct.
Pre-Condition: ct con almeno un elemento
Post-Condition: ct intersecato a Collection c
Expected Results: ris is true
-
containsAll_c
public void containsAll_c()Summary: test metodo containsAll(Collection c) e verifico che gli elementi di c siano presenti in ct
Test Case Design: containsAll method is invoked.
Test Description: containsAll method is invoked.
Pre-Condition: ct contiene tutti gli elementi presenti nella Collection c
Post-Condition: ris e' true
Expected Results: ris è true
-
equals_o
public void equals_o()Summary: test metodo equals(Object o) e controllo se sono uguali
Test Case Design: Tests equals behaviour with 4 equals objects.
Test Description: Collection are made equal, then equals is invoked.
Pre-Condition: due oggetti uguali
Post-Condition: ris vale true
Expected Results: ris is true
-
clear
public void clear()Summary: clear method test case. svuotare il ct e testare se e' vuoto
Test Case Design: Invokes clear method on an collection
Test Description: Calls clear on the collection, then it should be empty
Pre-Condition: ct contiene almeno un elemento
Post-Condition: non ci sono piu' value in ct
Expected Results: collection is Empty
-
is_empty
public void is_empty()Summary: isEmpty method test case. test metodo isEmpty() e controllo che ct sia vuoto attraverso il metodo isEmpty()
Test Case Design: Invokes clear method on an collection then isEmtpy should return true
Test Description: Calls clear on the collection, then it should be empty, then isEmtpy should return true
Pre-Condition: ct contiene almeno un elemento
Post-Condition: ct vuoto, ris vale true
Expected Results: collection is Empty
-
size
public void size()Summary: size method test case. verifico se size e' uguale a 4
Test Case Design: Invokes size method on an collection
Test Description: calls size methon on a collection with 4 elements
Pre-Condition: ct con 4 elementi
Post-Condition: size = 4
Expected Results: size = 4
-
Size_Empty
public void Size_Empty()Summary: size, isEmpty method test case. The test case asserts that an empty map should have an empty values collection witch should have a size of zero and isEmpty call returning true. The map and the collection is not modified since its creation.
Test Case Design: The design is a simple assert of a size call and expected 0 size (empty).
Test Description: size and isEmpty methods are invoked on the map and on the values Collection.
Pre-Condition: The map and the values collection is empty.
Post-Condition: The map and the values collection is still empty.
Expected Results: The size method returns 0 and the isEmpty method returns true.
-
Size_1Element
public void Size_1Element()Summary: size, isEmpty method test case. The test case asserts that a map with one element should have an relative values collection with one element wich should have size of 1 and isEmpty call returning false. The map is modified before the asserts.
Test Case Design: The design is a simple assert of a size call and expected 1 size and not being empty.
Test Description: size and isEmpty methods are invoked on the map and on the values collection.
Pre-Condition: The map is empty.
Post-Condition: The map and coll contains entry 1=159 .
Expected Results: The size method returns 1 and the isEmpty method returns false.
-
Size_5Element
public void Size_5Element()Summary: size, isEmpty method test case. The test case asserts that a map and its relative values collection with five mappings should have a size of 5 and isEmpty call returning false. The map is modified before the asserts.
Test Case Design: The design is a simple assert of a size call and expected 5 size and not being empty.
Test Description: size and isEmpty methods are invoked on the collection.
Pre-Condition: The map is empty.
Post-Condition: The map and the collection contains five mappings.
Expected Results: The size method returns 5 and the isEmpty method returns false.
-
Size_160Element
public void Size_160Element()Summary: size, isEmpty method test case. The test case asserts that a map and its relative values collection with five mappings should have a size of 160 and isEmpty call returning false. The map is modified before the asserts.
Test Case Design: The design is a simple assert of a size call and expected 160 size and not being empty.
Test Description: size and isEmpty methods are invoked on the collection.
Pre-Condition: The map is empty.
Post-Condition: The map and the collection contains five mappings.
Expected Results: The size method returns 160 and the isEmpty method returns false.
-
Contains_EmptyColl
public void Contains_EmptyColl()Summary: contains method test case.
Test Case Design: Tests the limit case of invoking the method in an empty collection wich should always return false.
Test Description: value 'ci' is tested to be present in the collection.
Pre-Condition: The map and the collection is empty.
Post-Condition: The map and the collection is unchanged, still empty.
Expected Results: contains returns false.
-
Contains_1
public void Contains_1()Summary: contains method test case.
Test Case Design: Test the case of invoking the method before put and after put mappings on the map
Test Description: an values is tested to be present in the collection before and after put the mappings in the map.
Pre-Condition: The map and the collection is empty.
Post-Condition: The map and the collection contains a mapping: "mio"="ci"
Expected Results: contains return false when the value is not present, true otherwhise.
-
Contains_50to100
public void Contains_50to100()Summary: contains method test case.
Test Case Design: The test case checks in various situation its internal state with contains.
Test Description: Numbers from 50 (included) to 100 (excluded) are added, then checks if elements from 25 to 125 are contained in the collection in 3 different steps.
- {25:50} not contained (beginning).
- {50:100} contained (middle).
- {100:125} not contained (ending).
Pre-Condition: The map is empty.
Post-Condition: The map and the collection is not empty.
Expected Results: The collection contains the right elements during execution.
-
Contains_Null_NPException
public void Contains_Null_NPException()Summary: contains method test case. Calling the contains method with null key in this values collection should throw NullPointerException runtime exception.
Test Case Design: The test expects the aforementioned exception to be thrown after a contains method invoke with null key.
Test Description: contains method gets called with null key.
Pre-Condition: Map and Collection is empty.
Post-Condition: Map and Collection is empty.
Expected Results: NullPointerException has been trown.
-
Equals_1
public void Equals_1()Summary: equals method test case.
Test Case Design: equals method is tested with an equal. The returned values should be true.
Test Description: Maps is initialized, then equals invoke are asserted
Pre-Condition: maps contains 1=1
Post-Condition: Maps and Collections are unchanged.
Expected Results: The two Collections are equal
-
Equals_Empty_True
public void Equals_Empty_True()Summary: equals method test case. The test case the method behaviour with 2 empty Collection.
Test Case Design: When both Collections are empty the equals method should return true because an empty Collection is equal to an empty Collection.
Test Description: Single assert, coll1.equals(coll2) invoked.
Pre-Condition: Both maps and Collections are empty.
Post-Condition: Both Collections are empty.
Expected Results: equals returns true.
-
Equals_Reflective
public void Equals_Reflective()Summary: equals method test case. The reflective property of equal method is tested.
Test Case Design: equals method should be reflective, therefore x.equals(x) should always return true.
Test Description: The test invokes coll.equals(coll) when coll is empty, when it has 10 elements and when it has 1000 elements.
Pre-Condition: The map is empty.
Post-Condition: The map and the collection has 1000 elements.
Expected Results: The values collection equals itself
-
Equals_Transitive
public void Equals_Transitive()Summary: equals method test case. The transitive property of equal method is tested.
Test Case Design: equals method should be transitive
Test Description: The test invokes coll1.equals(coll2) and coll2.equals(coll3) and coll1.equals(coll3)
Pre-Condition: The tree maps contains the 30 same mappings
Post-Condition: The maps and collection is unchanged
Expected Results: Equals has transitive property.
-
Clear_Empty
public void Clear_Empty()Summary: clear method test case.
Test Case Design: Invokes clear method on an already empty collection, which is a limit case.
Test Description: Calls clear on the collection, then it should be empty
Pre-Condition: map and collection is empty.
Post-Condition: maps and collection is still empty.
Expected Results: collection is Empty
-
Clear_1toEmtpy
public void Clear_1toEmtpy()Summary: clear method test case.
Test Case Design: Invokes clear method on a collection containing 1.
Test Description: Calls clear on the collection, then it should be empty
Pre-Condition: The map contains 1=1, the collection contains 1
Post-Condition: The map and collection is empty.
Expected Results: collection is Empty
-
Clear_1000toEmtpy
public void Clear_1000toEmtpy()Summary: clear method test case.
Test Case Design: Invokes clear method on a collection containing {0:1000}.
Test Description: Calls clear on the collection, then it should be empty
Pre-Condition: The map and the collection contains 1000 elements
Post-Condition: The map and the collection is empty.
Expected Results: collection is empty
-
HashCode_Prop
public void HashCode_Prop()Summary: hashCode test case. Tests the behaviour of hashCode method with different configurations.
Test Case Design: The same operations are applied to map 1 and 2, so they must have the same elements each time, and so they must have the same values collection each time, therefore they are equals. If they are equals they must have the same hashCode.
Test Description: Different configurations have been tested: empty, 1=1, "ciao"=164, "ciao"=0:10
Pre-Condition: Collections have same hashCode and they are equal.
Post-Condition: Collections have same hashCode and they are equal.
Expected Results: Collections have same hashCode and they are equal.
-
Add
public void Add()Summary: add method test case.
Test Case Design: The methoud throws UnsupportedOperationException.
Test Description: add is invoked.
Pre-Condition: coll1 is empty.
Post-Condition: coll1 is empty.
Expected Results: The add method is not supported. UnsupportedOperationException is thrown.
-
AddAll
public void AddAll()Summary: addAll method test case.
Test Case Design: The methoud throws UnsupportedOperationException.
Test Description: addAll is invoked.
Pre-Condition: coll1 is empty.
Post-Condition: coll1 is empty.
Expected Results: The addAll method is not supported. UnsupportedOperationException is thrown.
-
Remove_EmptyNull_NPException
public void Remove_EmptyNull_NPException()Summary: remove method test case. Calling the remove method with null key in this values collection should throw NullPointerException runtime exception.
Test Case Design: The test expects the aforementioned exception to be thrown after a remove method invoke with null key.
Test Description: remove method gets called with null key.
Pre-Condition: Map and Collection is empty.
Post-Condition: Map and Collection is empty.
Expected Results: NullPointerException has been trown.
-
Remove_Null_NPException
public void Remove_Null_NPException()Summary: remove method test case. Calling the remove method with null key in this values collection should throw NullPointerException runtime exception.
Test Case Design: The test expects the aforementioned exception to be thrown after a remove method invoke with null key.
Test Description: remove method gets called with null key.
Pre-Condition: Map and Collection contains 450 elements.
Post-Condition: Map and Collection are unchanged.
Expected Results: NullPointerException has been trown.
-
Remove_Empty
public void Remove_Empty()Summary: remove method test case. Calling the remove method with a valid key in an empty values collection should return always false
Test Case Design: The test invokes remove method on an emtpy collection wich is a limit case in wich the remove method should always return false
Test Description: remove method gets called in an empty collection.
Pre-Condition: Map and Collection is empty.
Post-Condition: Map and Collection is still empty.
Expected Results: remove method should be return false
-
Remove_ReturnOldValue
public void Remove_ReturnOldValue()Summary: remove method test case.
Test Case Design: Tests the remove method feature that returns the old value and after call remove method the collection does not contains the value
Test Description: Put an mappings into the map. Then assert that he remove the 987 values. Then assert that an second remove with the same key return null, because its not present yet.
Pre-Condition: Map has 44=987 mappings and values collection has 987
Post-Condition: Collection is empty.
Expected Results:remove method works properly
-
Remove_NotPresent
public void Remove_NotPresent()Summary: remove method test case.
Test Case Design: Tests the remove method in a case where the collection does not contain the key.
Test Description: remove is invoked with 2 different uncontained values.
Pre-Condition: Map contains "ciao"="bello". Values collection contains "bello"
Post-Condition: Map and collection is unchanged.
Expected Results: removes returns false.
-
Remove_450ToEmpty
public void Remove_450ToEmpty()Summary: remove method test case.
Test Case Design: Removes all the elements through remove method to test its behaviour. Note that the limit case of removing the last element is tested too.
Test Description: Calls remove 450 times on an collection containing 450 elements, making it empty.
Pre-Condition: Map contains 450 mappings. Values collection contains also 450 elements
Post-Condition: Map and collection is empty.
Expected Results: collection is empty, obviusly its size is 0.
-
RemoveAll_EmptyNull_NPException
public void RemoveAll_EmptyNull_NPException()Summary: removeAll method test case. Calling the removeAll method with null key in this values collection should throw NullPointerException runtime exception.
Test Case Design: The test expects the aforementioned exception to be thrown after a removeAll method invoke with null key.
Test Description: removeAll method gets called with null key.
Pre-Condition: Map and Collection is empty.
Post-Condition: Map and Collection is empty.
Expected Results: NullPointerException has been trown.
-
RemoveAll_Null_NPException
public void RemoveAll_Null_NPException()Summary: removeAll method test case. Calling the removeAll method with null key in this values collection should throw NullPointerException runtime exception.
Test Case Design: The test expects the aforementioned exception to be thrown after a removeAll method invoke with null key.
Test Description: removeAll method gets called with null key.
Pre-Condition: Map and Collection contains 450 elements.
Post-Condition: Map and Collection are unchanged.
Expected Results: NullPointerException has been trown.
-
RemoveAll_EmptyCollArg
public void RemoveAll_EmptyCollArg()Summary: removeAll method test case.
Test Case Design: removeAll method called with empty collection as an argument, which is a method's limit case.
Test Description: The test adds 45 elements to the map then generates the values collection and then calls removeAll with an empty collection. Therefore the maps should be unchanged.
Pre-Condition: The maps and coll1 contains 45 elements.
Post-Condition: The maps and coll1 are unchaged.
Expected Results: The maps are unchanged, therefore removeAll returns false, coll1 is unchanged.
-
RemoveAll_EmptyColl
public void RemoveAll_EmptyColl()Summary: removeAll method test case.
Test Case Design: removeAll method called in an empty collection with an nonempty collection as argument, which is a method's limit case.
Test Description: The test adds 45 elements to the map then generates the values collection and then calls removeAll on an empty collection. Therefore the maps should be unchanged.
Pre-Condition: The maps and coll1 contains 45 elements. collE is empty
Post-Condition: The maps and coll1 are unchaged. collE is empty
Expected Results: The maps are unchanged, therefore removeAll returns false, coll1 is unchanged. collE is still empty
-
RemoveAll_10to20Remove100
public void RemoveAll_10to20Remove100()Summary: removeAll method test case.
Test Case Design: removeAll method called between two collections. coll2 includes all elements of the coll1
Test Description: The test adds 100 elements to the map1 and 10 elements to the map2 wich are all in common with map1 then generates the values collection and then calls removeAll with coll2 as argument. Therefore the map1 should be changed and map2 should be unchanged.
Pre-Condition: The map1 and coll1 contains 100 elements. coll2 contains 10 elements
Post-Condition: The map1 and coll1 are unchaged. coll2 is unchanged
Expected Results: The map1 and coll1 are changed, therefore removeAll returns true, coll2 is unchanged.
-
RemoveAll_duplicates
public void RemoveAll_duplicates()Summary: removeAll method test case.
Test Case Design: removeAll method called between two collections. coll2 includes all elements of the coll1
Test Description: The test adds two equal elements to map1 so that coll1 has 2 equal elements. Call removeAll in order to remove the duplicates elements
Pre-Condition: the map1 and coll1 contains 2 elments. coll2 contains 1 elements
Post-Condition: The map1 and coll1 is changed. coll2 is unchanged
Expected Results: removeAll removes duplicates elements
-
RetainAll_EmptyNull_NPException
public void RetainAll_EmptyNull_NPException()Summary: retainAll method test case. Calling the retainAll method with null key in this values collection should throw NullPointerException runtime exception.
Test Case Design: The test expects the aforementioned exception to be thrown after a retainAll method invoke with null key.
Test Description: retainAll method gets called with null key.
Pre-Condition: Map and Collection is empty.
Post-Condition: Map and Collection is empty.
Expected Results: NullPointerException has been trown.
-
ReretainAll_Null_NPException
public void ReretainAll_Null_NPException()Summary: retainAll method test case. Calling the retainAll method with null key in this values collection should throw NullPointerException runtime exception.
Test Case Design: The test expects the aforementioned exception to be thrown after a retainAll method invoke with null key.
Test Description: retainAll method gets called with null key.
Pre-Condition: Map and Collection contains 450 elements.
Post-Condition: Map and Collection are unchanged.
Expected Results: NullPointerException has been trown.
-
RetainAll_EmptyCollArg
public void RetainAll_EmptyCollArg()Summary: retainAll method test case.
Test Case Design: retainAll method called with empty collection as an argument, which is a method's limit case.
Test Description: The test adds 45 elements to the map then generates the values collection and then calls retainAll with an empty collection. Therefore the maps should be changed.
Pre-Condition: The map and coll1 contains 45 elements. collE is empty
Post-Condition: The map and coll1 are chaged. collE is still empty
Expected Results: The map and coll1 changed, therefore retainAll returns true, coll1 is changed.
-
RetainAll_EmptyColl
public void RetainAll_EmptyColl()Summary: retainAll method test case.
Test Case Design: retainAll method called in an empty collection with an nonempty collection as argument, which is a method's limit case.
Test Description: The test adds 45 elements to the map then generates the values collection and then calls retainAll on an empty collection. Therefore the maps should be unchanged.
Pre-Condition: The maps and coll1 contains 45 elements. collE is empty
Post-Condition: The maps and coll1 are unchaged. collE is still empty
Expected Results: The maps are unchanged, therefore retainAll returns false, coll1 is unchanged.
-
RetainAll_10to20Retain100
public void RetainAll_10to20Retain100()Summary: retainAll method test case.
Test Case Design: retainAll method called between two collections. coll2 includes all elements of the coll1
Test Description: The test adds 100 elements to the map1 and 10 elements to the map2 wich are all in common with map1 then generates the values collection and then calls retainAll with coll2 as argument. Therefore the map1 should be changed and map2 should be unchanged.
Pre-Condition: The map1 and coll1 contains 100 elements. map2 and coll2 contains 10 elements
Post-Condition: The map1 and coll1 are chaged. map2 and coll2 is unchanged
Expected Results: The map1 and coll1 are changed, therefore retainAll returns true, coll2 and map2 is unchanged.
-
ContainsAll_EmptyNull_NPException
public void ContainsAll_EmptyNull_NPException()Summary: containsAll method test case. Calling the containsAll method with null key in this values collection should throw NullPointerException runtime exception.
Test Case Design: The test expects the aforementioned exception to be thrown after a containsAll method invoke with null key.
Test Description: containsAll method gets called with null key.
Pre-Condition: Map and Collection is empty.
Post-Condition: Map and Collection is empty.
Expected Results: NullPointerException has been trown.
-
ContainsAll_Null_NPException
public void ContainsAll_Null_NPException()Summary: containsAll method test case. Calling the containsAll method with null key in this values collection should throw NullPointerException runtime exception.
Test Case Design: The test expects the aforementioned exception to be thrown after a containsAll method invoke with null key.
Test Description: containsAll method gets called with null key.
Pre-Condition: Map and Collection contains 450 elements.
Post-Condition: Map and Collection are unchanged.
Expected Results: NullPointerException has been trown.
-
ContainsAll_Empty_False
public void ContainsAll_Empty_False()Summary: containsAll method test case. The method tests if an empty collection contains the elements of another collection, which is obviusly false.
Test Case Design: The test case tests the limit case of checking an empty collection containing something.
Test Description: The coll2 contains 45 elements. The containsAll method obviously should return false for any coll's content as the collection is empty.
Pre-Condition: The coll1 is empty. The coll2 contains 45 elements
Post-Condition: The colle1 is still empty. The coll2 is unchanged
Expected Results: The containsAll method return false.
-
ContainsAll_BothEmpty_True
public void ContainsAll_BothEmpty_True()Summary: containsAll method test case. The method tests if an empty collection contains the elements of another collection.
Test Case Design: The test case tests the limit case of checking an empty collection containing an empty collection, which is true, as the empty subset is the subset of every set, therefore even of the empty set. The tested case is a limit case of containsAll.
Test Description: The collection is empty. The containsAll method obviously should return true for any coll's content, because the empty subset is the subset of every set.
Pre-Condition: The collections is empty.
Post-Condition: The collections is empty.
Expected Results: The containsAll method return true.
-
ContainsAll_10to20contains100
public void ContainsAll_10to20contains100()Summary: containsAll method test case.
Test Case Design: containsAll method called between two collections. coll2 includes all elements of the coll1
Test Description: The test adds 100 elements to the map1 and 10 elements to the map2 wich are all in common with map1 then generates the values collection and then calls containsAll with coll2 as argument. Therefore the maps and coll should be unchanged.
Pre-Condition: The map1 and coll1 contains 100 elements. map2 and coll2 contains 10 elements
Post-Condition: the maps and coll should be unchanged.
Expected Results: the maps and coll should be unchanged. containsAll should return true as coll1 contains coll2 elements.
-
ContainsAll_10Notcontains100
public void ContainsAll_10Notcontains100()Summary: containsAll method test case.
Test Case Design: containsAll method called between two collections. coll2 includes elements different from the elements of the coll1
Test Description: The test adds 100 elements to the map1 and 10 elements to the map2 wich are not in common with map1 then generates the values collection and then calls containsAll with coll2 as argument. Therefore the maps and coll should be unchanged.
Pre-Condition: The map1 and coll1 contains 100 elements. map2 and coll2 contains 10 elements not present in coll1
Post-Condition: the maps and coll should be unchanged.
Expected Results: the maps and coll should be unchanged. containsAll should return false as coll1 not contains coll2 elements.
-
ToArray_Empty_EmptyArray
public void ToArray_Empty_EmptyArray()Summary: toArray method test case. The test case asserts that an empty collection should return an empty array on a toArray call. The collection is not modified since its creation.
Test Case Design: Tests the limit case of a toArray call returning an empty array.
Test Description: Test based on the trivial but possible state of an empty collection.
Pre-Condition: The collection is empty.
Post-Condition: The collection is still empty.
Expected Results: The toArray method returns an empty array and therefore its lenght is 0.
-
ToArray_OneElement
public void ToArray_OneElement()Summary: toArray method test case.
Test Case Design: Test the toArray method when the collection and the map contains only one element then checks if the collection element matches the inserted elements.
Test Description: Inserts 1=1 to the map. Then assertArrayEquals is called.
Pre-Condition: The collection and map is empty.
Post-Condition: The collection and map contains 1 element.
Expected Results: coll1.toArray() returns [1].
-
ToArray_ArrayDest_1
public void ToArray_ArrayDest_1()Summary: toArray test case. The test adds one element to the m and then call toArray method on the values collection.
Test Case Design: Test focuses on toArray behaviour when it has only one element, which is a limit case.
Test Description: Adds one to the collection, calls toArray method and checks the array's first element and its size.
Pre-Condition: The collection is empty.
Post-Condition: The collection has one element {1654}.
Expected Results: The element is stored correctly in the array returned from the method (the array is [1]) and its size is 1.
-
ToArray_DestNull_NPException
public void ToArray_DestNull_NPException()Summary: toArray(HCollection) method test case.
Test Case Design: The test checks the method behaviour when the argument is null, which a special case.
Test Description: If the specified array is null excpetion is being thrown.
Pre-Condition: The collection is empty
Post-Condition: The collection is still empty.
Expected Results: NullPointerExceptio is thrown.
-
ToArray_DestSmaller
public void ToArray_DestSmaller()Summary: toArray(HCollection) method test case. The collection has 2 elements and checks the array.
Test Case Design: The test checks the method behaviour when the argument size is not enough for containing the collection's elements, which a special case.
Test Description: arr contains the result of toArray method, but exception is being thrown.
Pre-Condition: The collection has 2 elements, arr is empty.
Post-Condition:The collection has 2 elements, arr is still empty.
Expected Results: HIllegalArgumentException is thrown.
-
ToString_Empty
public void ToString_Empty()Summary: toString method test case.
Test Case Design: Tests toString method on an empty collection.
Test Description: toString is invoked on a empty collection.
Pre-Condition: map1 and coll1 are empty.
Post-Condition: map1 and coll1 are empty.
Expected Results: coll1.toString return []
-
ToString_OneElement
public void ToString_OneElement()Summary: toString method test case.
Test Case Design: Tests toString method on a map containing 1=Ciaoooo so that values collection contains Ciaoooo
Test Description: toString is invoked on the collection.
Pre-Condition: map1 contains 1=Ciaoooo.
Post-Condition: map1 contains 1=Ciaoooo.
Expected Results: coll1.toString [Ciaoooo]
-
Backed_ClearPut
public void Backed_ClearPut()Summary: backing clear and put test case. Test the correct propagation values to map and viceversa by using the clear method on the map and on the collection and the put method on the map
Test Case Design: Using some assertion it test the backing of contents in the map and the collection before and after some put call and clear call.
Test Description: Test the backing of contents in the map and the collection before and after some put call and clear call.
Pre-Condition: map and coll is empty.
Post-Condition: map and coll is empty.
Expected Results: put and clear should add and remove elements from both side.
-
Backed_putAllRemove
public void Backed_putAllRemove()Summary: backing putall and remove test case. Test the correct propagation values to map and viceversa by using the remove method on the map and on the collection and the putall method on the map
Test Case Design: Using some assertion it test the backing of contents in the map and the collection before and after some putall call and remove call.
Test Description: Test the backing of contents in the map and the collection before and after some putall call and remove call.
Pre-Condition: map and coll is empty.
Post-Condition: map and coll is empty.
Expected Results: putall and remove should add and remove elements from both side.
-
Backed_PutRemove
public void Backed_PutRemove()Summary: backing put and remove test case. Test the correct propagation values to map and viceversa by using the remove method on the map and on the collection and the put method on the map
Test Case Design: Using some assertion it test the backing of contents in the map and the collection before and after some put call and remove call.
Test Description: Test the backing of contents in the map and the collection before and after some put call and remove call.
Pre-Condition: map and coll is empty.
Post-Condition: map and coll is empty.
Expected Results: put and remove should add and remove elements from both side.
-
Backed_IteratorRemove
public void Backed_IteratorRemove()Summary: backing remove with iterator test case. Test the correct propagation from values to map and viceversa by using the remove method of iterator
Test Case Design: Tests the iterator's remove method in a collection with 1000 elements util iterator has next element
Test Description: it invoke next and then remove until the iterator has the next element. Once he had finished the iterator clear all the collection. So the map and the collection is emtpy
Pre-Condition: map1 and coll1 has 1000 elements
Post-Condition: map1 and coll1 are empty
Expected Results: map1 and coll1 are empty, so the iterator correctly remove all elements
-
Backed_removeAll
public void Backed_removeAll()Summary: backing removeAll test case. Test the propagation from values to map and viceversa.
Test Case Design:Tests removeAll method with values HCollection. Correct propagation is tested in both ways.
Test Description: map1 contains 50 mappings, and coll1 as consequence contains 50 elements. map2 contains only 5 mappings in 20-25 range. After call removeAll all the elements in common between coll1 and coll2 will be removed.
Pre-Condition:map1 contains 50 mappings, coll1 contains 50 values, map2 contains 5 mappings and coll2 contains 5 values
Post-Condition: map2 and coll2 are unchanged. map1 and coll1 contains less elements.
Expected Results: the removeAll method correctly propagate the changes. Also removeAll method remove the elements in common between coll1 and coll2
-
Backed_retainAll
public void Backed_retainAll()Summary: baking retainAll test case. Test the propagation from values to map and viceversa.
Test Case Design:Tests retainAll method with values HCollection. Correct propagation is tested in both ways.
Test Description: map1 contains 50 mappings, and coll1 as consequence contains 50 elements. map2 contains only 5 mappings in 20-25 range. After call retainAll all the elements in common between coll1 and coll2 will retain.
Pre-Condition:map1 contains 50 mappings, coll1 contains 50 values, map2 contains 5 mappings and coll2 contains 5 values
Post-Condition: map2 and coll2 are unchanged. map1 and coll1 contains less elements.
Expected Results: the retainAll method correctly propagate the changes. Also retainAll method retain the elements in common between coll1 and coll2
-
Iterator_HasNext_Emtpy
public void Iterator_HasNext_Emtpy()Summary: hasNext and next methods test case.
Test Case Design: Tests the limit case of an iterator returned from an empty collection calling hasNext and next.
Test Description: an iterator is returned from empty collection. iterator.hasNext() should be false, while next() should throw NoSuchElementException.
Pre-Condition: The collection is empty.
Post-Condition: The collection is still empty.
Expected Results: hasNext returns false, NSEE is thrown.
-
Iterator_HasNext_Begin1_True
public void Iterator_HasNext_Begin1_True()Summary: hasNext and next methods test case. collection contains 1 element and the test iterate through it.
Test Case Design: Tests the limit case of 1 element in the collection. Therefore hasNext should return true while next() should return the only number in the collection.
Test Description: The number 1 is added, and an iterator iterates through the collection. After returning the first elements, it has no more next elements.
Pre-Condition: collection contains 1, iterator has next.
Post-Condition: collection contains 1, iterator has not next.
Expected Results: The first hasNext call returns true, the second returns false.
-
Iterator_Next_1
public void Iterator_Next_1()Summary:iterator next method test case
Test Case Design: Tests that next method return the correct elements
Test Description: Simply call next method on an collection contains 1 elements
Pre-Condition:map and coll contains 1 elements
Post-Condition: map and coll are unchanged
Expected Results: next return 1 and hasnext is false
-
Iterator_Remove_Empty_HISE
public void Iterator_Remove_Empty_HISE()Summary: remove method test case. Test should throw an exception.
Test Case Design: Tests if for a collection a remove method throws IllegalStateException on an emtpy collection
Test Description: remove is invoked by an iterator instance on an emtpy coll.
Pre-Condition: collection is emtpy.
Post-Condition: collection is emtpy.
Expected Results: HIllegalStateException thrown.
-
Remove_OneElement_HISE
public void Remove_OneElement_HISE()Summary: remove method test case. Test should throw an exception.
Test Case Design: Tests if for a collection a remove method throws IllegalStateException, as no prev or next has been called, or remove or add have been called after the last call to next or previous
Test Description: remove is invoked by an iterator instance.
Pre-Condition: collection has 1 element.
Post-Condition: collection still has 1 element.
Expected Results: IllegalStateException thrown.
-