CS计算机代考程序代写 Java junit Software Testing

Software Testing
Lab

Task for this week
▪ 1) Implement test cases using Junit
▪ 2) Implement a minimum number of Junit test cases for the given method to achieve
path complete.
▪ The code structure/skeleton is available on Wattle
▪ This lab contains assessable items!
▪ Submission Guidelines
▪ Thelastslidecontainsinformationaboutthesubmission ▪ Readitcarefullytoavoidlosingmarks!
2

Task 1 – Finding the correct implementation!
The goal of this task is to give you an idea on how assessable items will be evaluated throughout the semester. Most of the lab-related activities and final exam will be auto-graded via test cases. We will use JUnit4, which provides a simple way of creating unit tests for an application you are developing.
Task:
10 versions of a calculateMark method has
been written, but ONLY ONE is correct!
The task is to write JUnit tests to determine which of these implementations are incorrect.
3

Task 1 – Finding the correct implementation!
Follow the steps below:
1) Download a copy of the code but do not read the code for the different implementations (i.e. the code
in MarkCalculator0.java, MarkCalculator1.java, …, MarkCalculator9.java). Your tests should be driven by the specification only. (It will be more difficult to try to understand all implementations than writing the tests following the specification! Believe me! ☺).
2) Read the MarkCalculator.java file. This file includes an interface and a comment that provides an exact specification of what the calculateMark method does. Identify test cases from the interface specification.
Hint: before start implementing anything, think about the cases: boundary cases, cases you expect to fail, and maybe some random cases that you expect to succeed.
4

Task 1 – Finding the correct implementation!
3) Read MarkCalculatorTest.java. This file implements base JUnit testing framework with ParameterizedTest.
– There is an ArrayList that create instances of MarkCalculator (each array position has a MarkCalculator instance with different implementations).
– Note that for each test, a different instance of the MarkCalculator will be executed.
5

Task 1 – Finding the correct implementation!
4) Implement a set of test methods and cases, identified in the previous step, that aims to uncover errors in the implementation (black box testing) into MarkCalculatorTest.java.
6

Task 1 – Finding the correct implementation!
Which implementations passed your tests?
NOW read over the code and see if you can spot any errors (code review). Create some other test cases based on being able to view the code (white box testing).
Additionally, think about what would be the minimum number of tests case that are statement/branch/path complete for the different implementations?
Which implementation now passes your tests? Did your code review spot any errors?
Now which implementations passed your tests?
Which implementation is exactly correct?
Do you think JUnit tests can check code correctness? (Y/N, if No, why?)
These questions are for your reflection only.
7

Task 2 – Path Complete
The goal of this task is to give you an idea on how to create a minimum number of tests to achieve Path Complete.
Task:
Implement the minimum number of JUnit test cases for findSomething that is path complete.
8

Submission Guidelines
▪ Assignment deadline: see the deadline on Wattle (always!)
▪ Submission mode: via Wattle (Lab Testing)
▪ Each task worth 1 mark (total 2 marks)
▪ Task 1: For each calculator identified as incorrect implementation, 1/10 marks (the correct implementation is worth 1/10, but only if all incorrect ones are found). Any test case that fails all implementations will be discarded.
▪ Task 2: The minimum number of paths to achieve path complete was found: 1 mark. If more test cases than the minimum required were used: 0.5 marks; if test cases don’t cover all paths (only part of them): 0.2 marks. If no path is covered, 0 marks.
Submission format (IMPORTANT):
▪ Upload only your final version of MarkCalculatorTest.java and PathCompleteTest.java to Wattle
▪ Do not change the file names
▪ Do not upload any other files (only the specified files are needed)
▪ Do not upload a folder (your submission should be only the two java files).
▪ The answers will be marked by an automated marker.
▪ Do not change the structure of the source code including class name, package structure, etc.
▪ Youareonlyallowedtoeditthedesignatedcodesegmentindicatedinthecomments.
▪ Do not import packages outside of the standard java SE package. The list of available packages can be found here:
https://docs.oracle.com/en/java/javase/12/docs/api/index.html
▪ Any violation of the submission format will result in zero marks
9