Question: Practical Task In this practical task, you are going to write unit tests for one of your previous practical tasks. Follow the instructions below. Select
Practical Task
In this practical task, you are going to write unit tests for one of your previous
practical tasks. Follow the instructions below.
Select one of the more recent practical programming tasks you completed,
which will be referred to as your implementation.
Specify at least three use cases that you needed to implement for the
practical task.
Write unit tests that test your implementation against these use cases. We
suggest simplifying the tests you choose by testing the logic, because
testing the code with dependencies on a file or terminal will require that the
file or terminal be available at the time that you run your tests. You cannot
guarantee their availability, and this would complicate your workflow. If you
are interested in how such tests are performed, you can read about mock
testing and integration testing in your spare time.
You can add your unit tests at the end of the Python script containing your
implementation you would have chosen, assuming your implementation
involves a single Python file. If your implementation used multiple Python
files, feel free to create a testing Python script, which would import the
implementation scripts you will be testing.
If you find that your code is difficult to write unit tests for, congratulations!
You've discovered what it means to write testable code. You'll need to
refactor the implementation so that it's easier to write tests for.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
