In Project 03, you implemented a set of test scenarios that were designed to assess whether a class (StudentCollection) properly implements its functionalities. Testing was conducted under clear box guidelines - you had access to the source code, so via a code coverage tool you could:

  • determine the degree of thoroughness your testing had achieved, as well as
  • see the code paths that had not been completely tested

In Project 04 you are supplied with source code files for StudentCollection and StudentCollectionSpec and are to conduct "clear box" testing. There are two specific objectives for this project: assessment of the thoroughness of the unit tests implemented in Project 03 via use of a code coverage tool (specifically, JaCoCoverage), and the use of JUnit test reports to aid in discovering and eliminating problems in target test code.

Note that:

  • You are to test StudentCollection (the "target" class), and only that one class implementation.
  • You are to begin testing the supplied source code for StudentCollection by using your StudentCollectionTest as it existed at the end of Project 03.

You are supplied with one archive to be used as a resource in constructing the project associated with this lab, namely studentcollection.zip.

Important notes:

  • The StudentCollection implementation that you are testing in Project 04 is not the same implementation that was tested in Project 03. An appropriate way to approach Project 04: think of Project 03 as early-stage quality control conducted on a close-to-final version of StudentCollection. The development team then used the results from Project 03 to correct and enhance the implementation of StudentCollection; also, since time passed while Project 03 was developed and executed, project requirements may have changed. It is important that you review the documentation associated with the version of StudentCollection supplied with this project (which can be generated by right-clicking on the project in the project pane and choosing Generate Javadocs) and determine if any changes (additions, modification, edits) to requirements were made.
  • There may be functional errors in the supplied implementation of StudentCollection, which you are expected to detect and correct - see step P5 for details.

Project activities:

P1)Using Explorer, create a copy of your Project 03 project, naming the copy Project04ProjectYourLastName.

P2)Using Explorer, drill down to Project04ProjectYourLastName:

  • locate the src/studentcollection folder, delete the contents of the studentcollection subfolder, then expand the supplied studentcollection.zip archive into the src folder (when done correctly, the src folder will contain a studentcollection subfolder, which will contain two .java files).

P3)Open the project in NetBeans:

  • change the name of the project to Project04ProjectYourLastName
  • perform a clean and build - the project should compile cleanly and contain no syntax errors, and specifically no reference errors

P4)Review the requirements documentation for the StudentCollection being tested, comparing the requirements to those in place for Project 03 and noting any changes (additions, modifications, deletions).

P5)Locate and eliminate any problems revealed by executing StudentCollectionTest

Reminder - when creating a unit test, you are obligated to test all (100.0%) of the public methods within the target class

Reminder - to execute a JUnit test, give the StudentCollectionTest file focus in the editor, then right-click and choose Test File (or type CTRL+F6, or click the Test File button ( ) - a Test Results tab will appear in the output pane.

Execute the StudentCollectionTest file, determine if any test cases fail, and for all that do fail, proceed as follows.

  • Locate the cause of failure, potentially in either the StudentCollectionTest class (improper implementation of a test scenario or incorrect specification of an expected result, or possibly the result of a test scenario that needs to change because a requirement changed) or the supplied StudentCollection class (logic error in the implementation code). Remember, the JUnit report is hot-linked into the code, both StudentCollectionTest and StudentCollection...
Note – in cases where the current requirements specify one thing and the code does something else, assume that the requirements are correct and the code is incorrect. In the “real world”, you would talk to whoever is responsible for the requirements and to the developer who wrote the code (if either are still around) to determine which is correct – in the context of this academic project, do something that you really should not do in the real world and make the indicated assumption.
  • Determine the cause of the problem (which may or may not be near the statement that caused the test to fail - remember, finding the cause of a problem can be challenging), repair it, and re-execute the test to verify that you corrected the problem.
    • For all cases where you alter code in StudentCollection, document what amendments to the code you make to correct the code. Create a document named StudentCollectionCorrectionsYourLastName.docx, store it in the root folder of the project, and for each amendment indicate the method within StudentCollection that was changed, the line number(s) being changed, and the specific rational and nature of the amendment(s), e.g.
    • incorrect loop condition - changed "(insert original code here)" to "(insert modified code here)"
    • failure to verify that a parameter is non-null - inserted "(insert whatever you added for code here)".
    • failed to initialize a variable - inserted "(insert whatever you added for code here)".
    • For all cases where you alter / delete / add code in StudentCollectionTest, document what changes you made to correct the code - create a document named Project03-StudentCollectionTestScenariosAmendmentsYourLastName.docx by copying StudentCollectionTestScenariosAmendmentsYourLastName.docx (created during Project 03), store it in the root folder of the project, and for each amendment indicate the method within StudentCollectionTest that was altered / deleted / added and the specific rational and nature of the amendment(s), e.g.
    • Unnecessary (redundant) test scenario - deleted "(insert deleted code here)"
    • Additional test scenario to improve code coverage - inserted "(whatever you added for code here)"
    • Additional test scenario to verify a new requirement constraint - inserted "(insert whatever you added for code here)".
    • Modified test scenario to reflect a changed requirement constraint - requirement "(insert original requirement here)" replaced by requirement "(insert modified requirement here)", so changed test scenario "(insert original scenario here)" to "(insert modified scenario here here)".

P6)Assess the degree of code coverage that has been achieved

Determine and, if appropriate, improve the extent of code coverage your test cases have achieved.

  • Open the StudentCollection class, then open or give focus to StudentCollectionTest
  • Execute "Test with JaCoCoverage" (right-click project name, select Test with JaCoCoverage)
    • Note - JaCoCoverage can take a few seconds to complete, sometimes longer - if NetBeans' progress monitor (lower left corner) is active, then it's still working...
    • A report will be generated and presented in a web browser - for the time being, close or minimize the web browser report.
  • Give focus to StudentCollection and inspect the code to determine if there are any untested or under-tested statements (look for lines highlighted in yellow or red). If any such lines are located:
    • Design and implement additional test scenarios and, if necessary, additional test cases in order to increase the degree of code coverage. For all added test scenarios and/or test cases, insert appropriate documentation into the file named StudentCollectionTestScenariosAmendmentsYourLastName.docx, stored in the root folder of the project (see step P5 for details).
    • If you find that there are statements that cannot be fully tested (presumably because you cannot force a context in which they will be executed), document the statements in a Word document titled Project04-UndertestedStatementsYourLastName.docx (store at the root of the project folder). For each statement, include the name of the StudentCollection method that contains the statement, the actual statement (include a line number reference), and then explain why the statement cannot be fully tested.

Repeat (P5) until you have eliminated all failed tests and either covered all of the executable code or have documented why any under-covered or uncovered code cannot be fully covered.

P7)After finishing steps P4, P5, and P6 and before executing step P8, clear out unnecessary files from your project

  • Perform a "clean" of the project: right-click project name and choose "clean". After cleaning, do not perform a "clean and build" or an execution before execution step P8.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.