BEST代写-线上编程学术专家

Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

计算机代写|COM3529 Assignment 1

计算机代写|COM3529 Assignment 1

这是一篇来自英国的关于您将需要为下面four methods: `findLast`, `countPositive`, `lastZero`, and`oddOrPos`的每个缺陷编写JUnit测试,并建立一个修复的计算机代写,具体作业要求是对于`Assignment1.java`中的每个方法,您将需要回答以下问题,您需要作为PDF报告提交。

 

This assignment involves the `Assignment1.java` class that is part of the Gradle project that lives in the code directory of this repository. See [`code/lib/src/main/java/uk/ac/shef/com3529/Assignment1.java`](../code/lib/src/main/java/uk/ac/shef/com3529/Assignment1.java).

The class contains four methods: `findLast`, `countPositive`, `lastZero`, and`oddOrPos`.

Each method has a defect. You will need to write JUnit tests for each defect and establish a fix.

Specifically, for each method in `Assignment1.java`, you will need to answer the following questions, which you’ll need to submit as a PDF report. The tests you write should be added to a class called `Assignment1Test.java` (NB: When naming tests, `[methodName]` should be replaced by the name of the method you are writing the test for.)

  1. (a) What and where is the defect?  *[1 mark]*

(b) Under what condition(s) do inputs to the method cause it to fail?*[1 mark]*

(c) Write ONE JUnit test case that causes the method to fail.

This should be called `[methodName]_failure`. (Note that the test should also fail – i.e., the test should have an assertion for the _correct_ behaviour of the method.)*[1 mark]*

  1. (a) Is it possible for inputs to the method to _not_ execute the defect? If so, describe the condition(s) necessary for the inputs to the method that would cause this to happen. *[1 mark]*

(b) If possible (as per your answer to part (a)), write ONE JUnit test case that demonstrates the scenario of part (a) of this question.

This should be called `[methodName]_defectNotExecuted`.*[1 mark if test is possible]*

  1. (a) Is it possible for an input to execute the defect but _not_ infect the program’s state? If so, describe the condition(s) necessary for the inputs to the method that would cause this to happen.*[1 mark]*

(b) If possible (as per your answer to part (a)), write ONE JUnit test case that demonstrates the scenario of part (a) of this question.

Call it `[methodName]_defectExecuted_noInfection`. *[1 mark if test is possible]*

 

  1. (a) Is it possible for an input to cause an infection but _not_ cause the method to fail? (Note, program statements being executed when they shouldn’t count as an infection.) If so, describe the condition(s) necessary for the inputs to the method that would cause this to happen.*[1 mark]*

(b) If possible (as per your answer to part (a)), write ONE JUnit test case that demonstrates the scenario of part (a) of this question.

Call it `[methodName]_defectExecuted_infectionCaused_noFailure`.

*[1 mark if test is possible]*

 

  1. Fix the defect and add the fixed method to a class called `Assignment1Fixed.java`. (Ensure the test you wrote as part of Question 1 passes when run with the fixed version of the method.) *[1 mark]*

## Submission of Materials

You will need to submit three files:

  1. A short report, in PDF format, that should answer each of the questions above for each method that appears in `Assignment1.java`.

Where you are able to write a test, add it to a class `Assignment1Test.java`.

  1. Your test class, `Assignment1Test.java`.
  2. Your fixed version of the original class, called `Assignment1Fixed.java`.

 

These three items should be submitted submitted via the [Assessment

page](https://vle.shef.ac.uk/webapps/blackboard/content/listContentEditable.jsp?content_id=_5917864_1&course_id=_102825_1&mode=reset)

of the COM3529 module on Blackboard.

The deadline for this work to be handed in is **Wednesday 1st March, 5pm.**

## Marking Scheme

Up to one point will be allocated for each correct answer to each question as

indicated above.

## Unfair Means

This assignment is to **completed by yourself, on your own**. [Standard department procedures apply

with respect to unfair means.](https://sites.google.com/sheffield.ac.uk/comughandbook/your-study/assessment/unfair-means?authuser=0)

bestdaixie

评论已关闭。