Discuss why we need both mocking and stubbing instead

Assignment Help Software Engineering
Reference no: EM133673725

Task: Integration testing by mocking and stubbing dependencies

Overview
Integration testing, specifically the top­down approach, requires mocking (or stubbing) leaf modules down in the hierarchy to test the functionality of a higher­level module. In this task BodyTemperatureMonitor.java is created which depends on three dependent modules including TemperatureSensor.java, CloudService.java and NotificationSender.java. You will need to write test codes for pre­defined JUnit test functions in BodyTemperatureMonitorTest.java to achieve above 90% code coverage. You may need to mock or stub the dependent modules to test BodyTemperatureMonitorTest.java. Discuss why we need both mocking and stubbing instead of any one of them with proper references; find use cases from Deakin's internal websites such as unit site, OnTrack or any other.

Submission details
Use the instructions on the following page to carry out this task's steps.
For this task you will need to study the existing project task7_2P.zip which contains source and test files in sit707_week7 package in corresponding source and test folders in Eclipse project. The test subpackage sit707_week7.sample contains an example on how to use mocks and stubs and perform unit tests. You need to update the test java file as required, use mocks and stubs and achieve above 90% code coverage.

Submit a pdf combining below items ­
A screenshot of your Eclipse IDE's (i) JUnit tab which shows test statistics including Runs, Errors and Failures and (ii) Emma coverage output which shows coverage statistics including percentage coverage per java file and corresponding number of instructions covered/missed.
Your program's source code for tests BodyTemperatureMonitorTest.java
Comparative analysis between mocking and stubbing with use cases drawn from Deakin's internal websites.
A screenshot of your github page where your latest project folder is pushed.
You want to focus on the following key ideas, and make sure you can explain them in relation to your program.
Integration testing - top­down and bottom­up approach.
Mocking and stubbing in the context of integration tests - where to use what.

Instructions

For this task you will need to
Download task7_1P.zip Java project and unzip it in a common folder (say, java_projects) which you will be using to store all the weekly projects.
Import the project (as a maven project) in Eclipse IDE.

Observe java files in package sit707_week7.sample in test folder which has a single java test file StudentReaderTest.java with below test functions. These test functions used classes and methods defined in java files in the same sit707_week7.sample package in source folder.


testFindStudent() Stubs StudentRepository class to test
StudentReader.findFullName() function.
testStudentRepoSave() Stubs StudentRepository class to test
StudentReader.createNew() function.
testEmailSend() Mocks EmailSender.sendEmail() function that it is
called once by StudentReader.notifyStudent() function.
testEmailNoSend() A version of testEmailSend() above where mock
sendEmail() is never called by StudentReader.

The BodyTemperatureMonitor.java file is the source that you need to test. This file contains below member attributes and functions.


Member attributes Description
TemperatureSensor temperatureSensor Dependency module to be mocked
NotificationSender notificationSener Dependency module to be mocked
CloudService cloudService Dependency module to be mocked
Member Functions
BodyTemperatureMonitor(TemperatureSens
or, CloudService, NotificationSender) Constructor which takes 3 dependencies as
parameters.
readTemperature() Calls readTemperatureValue() of
temperatureSensor module.
reportTemperatureReadingToCloud() Calls sendTemperatureToCloud() of
cloudService module.
InquireBodyStatus() Calls queryCustomerBodyStatus() of cloudService and receives either NORMAL or ABNORMAL status. In former status email notification to user is sent but an emergency notification to family­doctor is sent for the
later status condition.

A test file BodyTemperatureMonitorTest.java in test package sit707_week7 contains failed test cases which you will need to fill in with codes and make them pass. The test functions are listed below.


testReadTemperatureNegative() Stub temperatureSensor to return
negative temperature reading.
TestReadTemperatureZero() Stub temperatureSensor to return 0
temperature reading.
TestReadTemperatureNormal() Stub temperatureSensor to return temperature reading between 35­37
degree celcius.
TestReadTemperatureAbnormallyHigh() Stub temperatureSensor to return
abnormally high value.
TestReportTemperatureReadingToCloud() Mock cloudService so it's sendTemperatureToCloud is called
once.
TestInquireBodyStatusNormalNotification() Stub cloudService queryCustomerBodyStatus to return status NORMAL so can mock
notificationSender's

sendEmailNotification(Customer)
method.
TestInquireBodyStatusAbnormalNotification() Stub cloudService queryCustomerBodyStatus to return status ABNORMAL so can mock notificationSender's sendEmailNotification(FamilyDoctor)
method.

There are 2 test failures that you need to correct by providing your name and id in the first 2 test cases.
Make sure you achieve above 90% code coverage for BodyTemperatureMonitor.java and its test file.
Run the test, take screenshot of code coverage statistic.
Upload your folder to your GitHub account and take a screenshot.

Your Task
Your task is to:
Study sample package sit707_week7.sample in source and test folder to understand StudentReader.java and how the test file StudentReaderTest.java uses mocks and stubs to test the StudentReader.
Now study BodyTemperatureMonitor.java class attributes and functions which you will need to test. It contains dependencies as member attributes which you need to mock or stub to pass the tests in BodyTemperatureMonitorTest.java test file.
Run the test file Coverage As > JUnit Test to see the coverage output and code highlight.
Try to achieve above 90% code coverage at the source and test java file.

Reference no: EM133673725

Questions Cloud

Integrate web front­end with java api : Integrate web front­end with Java API back end as part of integration testing - Development of front and back ends may progress separately
Describe the qualities that you think are most important : Describe the qualities that you think are most important for someone to be recognized as a conscious leader. How to develop the qualities you described above.
Programmer uses algorithm : A programmer uses an algorithm that will determine if a number is odd or even using modulus.
What are three virtues that you think are most important : What are two or three virtues that you think are most important in our personal lives and in our business affairs and explain why you selected those?
Discuss why we need both mocking and stubbing instead : Integration testing by mocking and stubbing dependencies - Discuss why we need both mocking and stubbing instead of any one of them with proper references
Create two separate functions satisfying both the conditions : Create two separate functions satisfying both the conditions of part B - (a) a loop with simple statement and (b) a loop with conditional statement
Explain the potential negative impacts on the company : Identify one of the 8 waste listed in the article and provide an example from a service industry company. Explain the potential negative impacts on the company.
Focus on basic SQL queries : This assignment will focus on basic SQL queries. The dataset on which you will execute the queries has been provided as SQL scripts.
Difference between persistence time and test function : Come up with an idea including stopping the clock or fake the clock so that the unit test runs successfully all the time

Reviews

Write a Review

Software Engineering Questions & Answers

  Many midsized firms are investing in erp system packages

many midsized firms are investing in erp system packages such as sap and peoplesoft.comment on what you think might be

  Performing the algorithm for insertafter

Draw a picture illustrating the final state of a doubly linked list after performing the algorithm for insertAfter(p, e), but with the order

  What is your opinion about software piracy

Why do many people feel that software piracy is not a serious crime? What is your opinion about software piracy? What can be done to stop this type of crime?

  What might be causing the slow response time

What might be causing the slow response time? Prepare a brief memo explaining system performance and workload measurement, using nontechnical language that Personal Trainer users can understand easily.

  Discuss relevant configuration management policies

Software Quality Assurance (COMP 30010) - evaluate and use tools and techniques to successfully handle configuration management

  Identify trends in mobile software development

Identify trends in mobile software development and explain why they are relevant to the scenario described above. Explain how the different mobile platform will affect the different phases of requirements, design, development, and deployment of the m..

  Management report style

Write a report on your findings in a management report style. This implies that the report begins with an executive summary, which briefly summarizes your findings.

  Analysis of service oriented architecture

Analysis of Service Oriented Architecture in Software Development - Software reuse approaches include the idea of class libraries, reusable components, application frameworks, patterns, and service oriented architecture.

  Write a program that reverses a singly linked list

iven the function below. What would happen if the first parameter would be struct node *list instead of struct node **list? Explain why.

  Designing and implementing an information system

Understand the methods and techniques involved in designing, implementing and maintaining an information system, in particular using an object-oriented approach

  What are the good and bad things about the it system

What are the good and bad things about the IT system? Who is the vendor? How much does the system cost? Was any training offered to the nurse prior

  Unit 34 System Analysis & Design Assignment

Unit 34 System Analysis & Design Assignment Help and Solution, Higher National Diploma in Computing - Assessment Writing Service

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd