Class TestSuiteKeySet
Summary: The TestSuiteKeySet provides test on keySet set methods.
It offer different type of test in differente case scanario, in order to test their correct behaviour.
There are several section for each method (or group of feature) contains
the test cases ideated by me.
Note that all the test contained in the TestSet.java file
assigned by the Professor, are just included in this test suite in JUnit format.
In the TestSet.java file there are some test with add method (unsupported in keySet) and some test of
the iterator removal, witch are included in the last section of this test suite. Also toString method is tested.
Test Suite Design: This test suite contains fine-grained different test cases
for each method of the HSet interface in order to individuate errors in HSet 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_key()
Summary: add method test case.void
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
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: containsAll method test case.void
Summary: containsAll method test case.void
Summary: containsAll method test case.void
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
Summary: equals method test case.void
Summary: equals method test case.void
Summary: hashCode 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: remove method test case.void
Summary: remove method test case.void
Summary: remove method test case.void
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: 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: 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
Summary: toArray method test case.void
Summary: toArray test case.void
Summary: toArray(HSet) method test case.void
Summary: toArray(HSet) method test case.void
Summary: toArray method test case.void
Summary: toString method test case.void
Summary: toString method test case.
-
Constructor Details
-
TestSuiteKeySet
public TestSuiteKeySet()
-
-
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 keyector. -
afterClassMethod
public static void afterClassMethod()AfterClass JUnit static method. Announces the the test end and stops its timer. Prints milliseconds elapsed from the beginning. -
Size_Empty
public void Size_Empty()Summary: size, isEmpty method test case. The test case asserts that an empty map should have an empty keySet set witch should have a size of zero and isEmpty call returning true. The map and the set 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 keySet set.
Pre-Condition: The map and the keySet set is empty.
Post-Condition: The map and the keySet set 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 keySet 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 keySet.
Pre-Condition: The map is empty.
Post-Condition: The map and set 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 keySetwith 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 set.
Pre-Condition: The map is empty.
Post-Condition: The map and the set 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 keySet 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 set.
Pre-Condition: The map is empty.
Post-Condition: The map and the set contains five mappings.
Expected Results: The size method returns 160 and the isEmpty method returns false.
-
Contains_Empty
public void Contains_Empty()Summary: contains method test case.
Test Case Design: Tests the limit case of invoking the method in an empty set wich should always return false.
Test Description: value 'ci' is tested to be present in the set.
Pre-Condition: The map and the set is empty.
Post-Condition: The map and the set 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 set before and after put the mappings in the map.
Pre-Condition: The map and the set is empty.
Post-Condition: The map and the set 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 set 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 set is not empty.
Expected Results: The set contains the right elements during execution.
-
Contains_Key_Null_NPException
public void Contains_Key_Null_NPException()Summary: contains method test case. Calling the contains method with null key in this keySet 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 set is empty.
Post-Condition: Map and set 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 sets are unchanged.
Expected Results: The two sets are equal
-
Equals_Empty_True
public void Equals_Empty_True()Summary: equals method test case. The test case the method behaviour with 2 empty set.
Test Case Design: When both sets are empty the equals method should return true because an empty set is equal to an empty set.
Test Description: Single assert,
key1.equals(key2)
invoked.Pre-Condition: Both maps and sets are empty.
Post-Condition: Both sets 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
key1.equals(key1)
when key 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 set has 1000 elements.
Expected Results: The keySet 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 key1.equals(key2) and key2.equals(key3) and key1.equals(key3)
Pre-Condition: The tree maps contains the 30 same mappings
Post-Condition: The maps and set 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 set, which is a limit case.
Test Description: Calls clear on the set, then it should be empty
Pre-Condition: map and set is empty.
Post-Condition: maps and set is still empty.
Expected Results: set is Empty
-
Clear_1Element
public void Clear_1Element()Summary: clear method test case.
Test Case Design: Invokes clear method on a set containing 1.
Test Description: Calls clear on the set, then it should be empty
Pre-Condition: The map contains 1=1, the set contains 1
Post-Condition: The map and set is empty.
Expected Results: set is Empty
-
Clear_0To1000
public void Clear_0To1000()Summary: clear method test case.
Test Case Design: Invokes clear method on a set containing {0:1000}.
Test Description: Calls clear on the set, then it should be empty
Pre-Condition: The map and the set contains 1000 elements
Post-Condition: The map and the set is empty.
Expected Results: set 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 keySet 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: sets have same hashCode and they are equal.
Post-Condition: sets have same hashCode and they are equal.
Expected Results: sets have same hashCode and they are equal.
-
Add_key
public void Add_key()Summary: add method test case.
Test Case Design: The methoud throws UnsupportedOperationException.
Test Description: add is invoked.
Pre-Condition: key1 is empty.
Post-Condition: key1 is empty.
Expected Results: The add method is not supported. UnsupportedOperationException is thrown.
-
AddAll_key
public void AddAll_key()Summary: addAll method test case.
Test Case Design: The methoud throws UnsupportedOperationException.
Test Description: addAll is invoked.
Pre-Condition: key1 is empty.
Post-Condition: key1 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 keySet 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 set is empty.
Post-Condition: Map and set 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 keySet 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 set contains 450 elements.
Post-Condition: Map and set 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 keySet should return always false
Test Case Design: The test invokes remove method on an emtpy set wich is a limit case in wich the remove method should always return false
Test Description: remove method gets called in an empty set.
Pre-Condition: Map and set is empty.
Post-Condition: Map and set 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 set does not contains the key
Test Description: Put an mappings into the map. Then assert that he remove the 44 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 keySet has 44
Post-Condition: Map and Set 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 set does not contain the key.
Test Description: remove is invoked with 2 different uncontained values.
Pre-Condition: Map contains "ciao"="bello". keySet contains "ciao"
Post-Condition: Map and set 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 set containing 450 elements, making it empty.
Pre-Condition: Map contains 450 mappings. keySet contains also 450 elements
Post-Condition: Map and set is empty.
Expected Results: set 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 keySet Set 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 Set is empty.
Post-Condition: Map and Set 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 keySet Set 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 Set contains 450 elements.
Post-Condition: Map and Set are unchanged.
Expected Results: NullPointerException has been trown.
-
RemoveAll_EmptykeyArg
public void RemoveAll_EmptykeyArg()Summary: removeAll method test case.
Test Case Design: removeAll method called with empty Set as an argument, which is a method's limit case.
Test Description: The test adds 45 elements to the map then generates the keySet Set and then calls removeAll with an empty Set. Therefore the maps should be unchanged.
Pre-Condition: The maps and key1 contains 45 elements.
Post-Condition: The maps and key1 are unchaged.
Expected Results: The maps are unchanged, therefore removeAll returns false, key1 is unchanged.
-
RemoveAll_Emptykey
public void RemoveAll_Emptykey()Summary: removeAll method test case.
Test Case Design: removeAll method called in an empty Set with an nonempty Set as argument, which is a method's limit case.
Test Description: The test adds 45 elements to the map then generates the keySet Set and then calls removeAll on an empty Set. Therefore the maps should be unchanged.
Pre-Condition: The maps and key1 contains 45 elements. keyE is empty
Post-Condition: The maps and key1 are unchaged. keyE is empty
Expected Results: The maps are unchanged, therefore removeAll returns false, key1 is unchanged. keyE is still empty
-
RemoveAll_10to20Remove100
public void RemoveAll_10to20Remove100()Summary: removeAll method test case.
Test Case Design: removeAll method called between two Sets. key2 includes all elements of the key1
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 Set and then calls removeAll with key2 as argument. Therefore the map1 should be changed and map2 should be unchanged.
Pre-Condition: The map1 and key1 contains 100 elements. key2 contains 10 elements
Post-Condition: The map1 and key1 are unchaged. key2 is unchanged
Expected Results: The map1 and key1 are changed, therefore removeAll returns true, key2 is unchanged.
-
RetainAll_EmptyNull_NPException
public void RetainAll_EmptyNull_NPException()Summary: retainAll method test case. Calling the retainAll method with null key in this keySet Set 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 Set is empty.
Post-Condition: Map and Set 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 keySet Set 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 Set contains 450 elements.
Post-Condition: Map and Set are unchanged.
Expected Results: NullPointerException has been trown.
-
RetainAll_EmptySetArg
public void RetainAll_EmptySetArg()Summary: retainAll method test case.
Test Case Design: retainAll method called with empty Set as an argument, which is a method's limit case.
Test Description: The test adds 45 elements to the map then generates the keySet Set and then calls retainAll with an empty Set. Therefore the maps should be changed.
Pre-Condition: The map and key1 contains 45 elements. keyE is empty
Post-Condition: The map and key1 are chaged. keyE is still empty
Expected Results: The map and key1 changed, therefore retainAll returns true, key1 is changed.
-
RetainAll_Emptykey
public void RetainAll_Emptykey()Summary: retainAll method test case.
Test Case Design: retainAll method called in an empty Set with an nonempty Set as argument, which is a method's limit case.
Test Description: The test adds 45 elements to the map then generates the keySet Set and then calls retainAll on an empty Set. Therefore the maps should be unchanged.
Pre-Condition: The maps and key1 contains 45 elements. keyE is empty
Post-Condition: The maps and key1 are unchaged. keyE is still empty
Expected Results: The maps are unchanged, therefore retainAll returns false, key1 is unchanged.
-
RetainAll_10to20Retain100
public void RetainAll_10to20Retain100()Summary: retainAll method test case.
Test Case Design: retainAll method called between two Sets. key2 includes all elements of the key1
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 keySet Set and then calls retainAll with key2 as argument. Therefore the map1 should be changed and map2 should be unchanged.
Pre-Condition: The map1 and key1 contains 100 elements. map2 and key2 contains 10 elements
Post-Condition: The map1 and key1 are chaged. map2 and key2 is unchanged
Expected Results: The map1 and key1 are changed, therefore retainAll returns true, key2 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 keySet Set 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 Set is empty.
Post-Condition: Map and Set 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 keySet Set 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 Set contains 450 elements.
Post-Condition: Map and Set 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 Set contains the elements of another Set, which is obviusly false.
Test Case Design: The test case tests the limit case of checking an empty Set containing something.
Test Description: The key2 contains 45 elements. The containsAll method obviously should return false for any key's content as the Set is empty.
Pre-Condition: The key1 is empty. The key2 contains 45 elements
Post-Condition: The keye1 is still empty. The key2 is unchanged
Expected Results: The containsAll method return false.
-
ContainsAll_BothEmpty_False
public void ContainsAll_BothEmpty_False()Summary: containsAll method test case. The method tests if an empty Set contains the elements of another Set.
Test Case Design: The test case tests the limit case of checking an empty Set containing an empty Set, 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 Set is empty. The containsAll method obviously should return true for any key's content, because the empty subset is the subset of every set.
Pre-Condition: The Sets is empty.
Post-Condition: The Sets 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 Sets. key2 includes all elements of the key1
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 keySet Set and then calls containsAll with key2 as argument. Therefore the maps and key should be unchanged.
Pre-Condition: The map1 and key1 contains 100 elements. map2 and key2 contains 10 elements
Post-Condition: the maps and key should be unchanged.
Expected Results: the maps and key should be unchanged. containsAll should return true as key1 contains key2 elements.
-
ContainsAll_10Notcontains100
public void ContainsAll_10Notcontains100()Summary: containsAll method test case.
Test Case Design: containsAll method called between two Sets. key2 includes elements different from the elements of the key1
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 keySet Set and then calls containsAll with key2 as argument. Therefore the maps and key should be unchanged.
Pre-Condition: The map1 and key1 contains 100 elements. map2 and key2 contains 10 elements not present in key1
Post-Condition: the maps and key should be unchanged.
Expected Results: the maps and key should be unchanged. containsAll should return false as key1 not contains key2 elements.
-
ToArray_Empty_EmptyArray
public void ToArray_Empty_EmptyArray()Summary: toArray method test case. The test case asserts that an empty set should return an empty array on a toArray call. The set is not modified since its creation.
Test Case Design: Tests the limit case of a toArray call returning an empty array. From the Sommerville: "Test with sequences of zero lenght."
Test Description: Test based on the trivial but possible state of an empty set.
Pre-Condition: The set is empty.
Post-Condition: The set is still empty.
Expected Results: The toArray method returns an empty array and therefore its lenght is 0.
-
ToArray_1_True
public void ToArray_1_True()Summary: toArray method test case.
Test Case Design: Test the toArray method when the set and the map contains only one element then checks if the set element matches the inserted elements.
Test Description: Inserts 1=1 to the map. Then assertArrayEquals is called.
Pre-Condition: The set and map is empty.
Post-Condition: The set and map contains 1 element.
Expected Results: key1.toArray() returns [1].
-
ToArray_ArrayDest_1
public void ToArray_ArrayDest_1()Summary: toArray test case. The test adds one element to the map and then call toArray method on the keySet.
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 set, calls toArray method and checks the array's first element and its size.
Pre-Condition: The set is empty.
Post-Condition: The set has one element {145}.
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(HSet) 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 set is empty
Post-Condition: The set is still empty.
Expected Results: NullPointerExceptio is thrown.
-
ToArray_DestSmaller
public void ToArray_DestSmaller()Summary: toArray(HSet) method test case. The set 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 set's elements, which a special case.
Test Description: arr contains the result of toArray method, but exception is being thrown.
Pre-Condition: The set has 2 elements, arr is empty.
Post-Condition: The set 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 set.
Test Description: toString is invoked on a empty set.
Pre-Condition: map1 and key are empty.
Post-Condition: map1 and key are empty.
Expected Results: key.toString return []
-
ToString_OneElement
public void ToString_OneElement()Summary: toString method test case.
Test Case Design: Tests toString method on a map containing Ciaoooo=1 so that key set contains Ciaoooo
Test Description: toString is invoked on the set.
Pre-Condition: map1 contains Ciaoooo=1.
Post-Condition: map1 contains Ciaoooo=1.
Expected Results: key.toString [Ciaoooo]
-
Backed_ClearPut
public void Backed_ClearPut()Summary: backing clear and put test case. Test the correct propagation keySet to map and viceversa by using the clear method on the map and on the set and the put method on the map
Test Case Design: Using some assertion it test the backing of contents in the map and the set before and after some put call and clear call.
Test Description: Test the backing of contents in the map and the set before and after some put call and clear call.
Pre-Condition: map and keyset is empty.
Post-Condition: map and keyset 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 keyset to map and viceversa by using the remove method on the map and on the set and the putall method on the map
Test Case Design: Using some assertion it test the backing of contents in the map and the set before and after some putall call and remove call.
Test Description: Test the backing of contents in the map and the set before and after some putall call and remove call.
Pre-Condition: map and keyset is empty.
Post-Condition: map and keyset 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 set and the put method on the map
Test Case Design: Using some assertion it test the backing of contents in the map and the set before and after some put call and remove call.
Test Description: Test the backing of contents in the map and the set before and after some put call and remove call.
Pre-Condition: map and keyset is empty.
Post-Condition: map and keyset 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 keySet to map and viceversa by using the remove method of iterator
Test Case Design: Tests the iterator's remove method in a set 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 set. So the map and the set is emtpy
Pre-Condition: map1 and keySet has 1000 elements
Post-Condition: map1 and keySet are empty
Expected Results: map1 and keySet are empty, so the iterator correctly remove all elements
-
Backed_removeAll
public void Backed_removeAll()Summary: backing removeAll test case. Test the propagation from keyset to map and viceversa.
Test Case Design:Tests removeAll method with keySet HSet. Correct propagation is tested in both ways.
Test Description: map1 contains 50 mappings, and key1 as consequence contains 50 elements. map2 contains only 5 mappings in 20-25 range. After call removeAll all the elements in common between key1 and key2 will be removed.
Pre-Condition:map1 contains 50 mappings, key1 contains 50 values, map2 contains 5 mappings and key2 contains 5 values
Post-Condition: map2 and key2 are unchanged. map1 and key1 contains less elements.
Expected Results: the removeAll method correctly propagate the changes. Also removeAll method remove the elements in common between key1 and key2
-
Backed_retainAll
public void Backed_retainAll()Summary: baking retainAll test case. Test the propagation from keyset to map and viceversa.
Test Case Design:Tests retainAll method with keySet HSet. Correct propagation is tested in both ways.
Test Description: map1 contains 50 mappings, and key1 as consequence contains 50 elements. map2 contains only 5 mappings in 20-25 range. After call retainAll all the elements in common between key1 and key2 will retain.
Pre-Condition:map1 contains 50 mappings, key1 contains 50 values, map2 contains 5 mappings and key2 contains 5 values
Post-Condition: map2 and key2 are unchanged. map1 and key1 contains less elements.
Expected Results: the retainAll method correctly propagate the changes. Also retainAll method retain the elements in common between key1 and key2
-
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 set calling hasNext and next.
Test Description: an iterator is returned from empty set. iterator.hasNext() should be false, while next() should throw NoSuchElementException.
Pre-Condition: The set is empty.
Post-Condition: The set 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. set contains 1 element and the test iterate through it.
Test Case Design: Tests the limit case of 1 element in the set. Therefore hasNext should return true while next() should return the only number in the set.
Test Description: The number 1 is added, and an iterator iterates through the set. After returning the first elements, it has no more next elements.
Pre-Condition: set contains 1, iterator has next.
Post-Condition: set 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 set contains 1 elements
Pre-Condition:map and set contains 1 elements
Post-Condition: map and set 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 set a remove method throws IllegalStateException on an emtpy set
Test Description: remove is invoked by an iterator instance on an emtpy set.
Pre-Condition: set is emtpy.
Post-Condition: set 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 set a remove method throws HIllegalStateException, 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: set has 1 element.
Post-Condition: set still has 1 element.
Expected Results: HIllegalStateException thrown.
-