Create two separate functions satisfying both the conditions

Assignment Help Software Engineering
Reference no: EM133673724

Task: Unit test and code coverage

Overview

Code coverage is a measure of the percentage of code that your unit tests execute. Emma is a code coverage tool that does the dirty work of taking the measurements. Emma can be installed as Eclipse IDE plugin. Part A: You will need to write JUnit test cases functions in WeatherAndMathUtils.java to achieve above 90% code coverage. Part B: you will need to investigate code coverage for (a) conditional loop and (b) conditional loop containing a conditional statement.

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 task6_1P.zip which contains WeatherAndMathUtils.java and a test file WeatherAndMathUtilsTest.java. You need to update the test java file as required to achieve above 90% code coverage.
Submit a pdf combining below items for both the parts (part A & B) ­
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 WeatherAndMathUtilsTest.java
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.
Code coverage and its significance and limitations
Path analysis of source code such as statement, conditional statement, conditional loop.

Instructions
For this task you will need to
Download task6_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 WeatherAndMathUtils.java file contains function weatherAdvice(double windSpeed, double precipitation) and two math functions isEven(num) and isPrime(num). The weatherAdvice function advice alert levels for different weather severity such as a dangerous level of alert if
More than 6.0 inches of rain are expected.
Wind speeds greater than 70.0 mph are predicted.
There will be over 4.0 inches of rain and wind speeds will be above 45.0 mph.
If none of the above conditions are met, a warning level alert is issued if any of the following conditions are met:
Predicted wind speeds are above 45.0 mph.
Predicted precipitation is above 4.0 inches.
An all­clear alert is generated for the rest of the normal conditions.

A test file WeatherAndMathUtilsTest.java contains a function to test a dangerous weather alert advice for 70.1 mph windspeed which is slightly above the maximum windspeed threshold. This file also contains a few other unsuccessful test functions. You can run this test file with Emma code coverage command in Eclipse (right­click test file > Coverage As > JUnit Test). Emma code­coverage plugin shows statistics and highlights both the test and source files. Figure below shows the highlighted weatherAdvice function body for code­coverage and statistics in Coverage console. The statistics show that the source package (src/main/java) has a total of 75 lines of code among which 19 statements were covered or tested by the test file and 56 remaining statements are yet to test. The statistics also show the coverage of the test file which shows among 24 instructions, 11 test instructions failed which you can see there are 3 tests which are failing.

Regarding part B, create another java file in the same package as WeatherAndMathUtilsTest.java file and write 2 functions: (a) the first function should contain a conditional loop (could be a for loop or while loop, if supported by the programming language) with simple instructions in the loop body and (b) the second function should contain a conditional loop with a conditional statement in the loop body. You need to create tests to achieve above 90% code coverage on these 2 functions.
There are 2 test failures that you need to correct by providing your name and id in the first 2 test cases.
You need to create more test cases and run the code coverage to improve the coverage above 90% in the source code WeatherAndMathUtils.java file and in the part B java 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 the functions in WeatherAndMathUtils.java (there are 3 of them) and a passed test function in WeatherAndMathUtilsTest.java test file.
Run the test file Coverage As > JUnit Test to see the coverage output and code highlight.
Add more test cases to achieve above 90% code coverage at the source java file.

Repeat above testing and code coverage steps for part B but for that you also need to create two separate functions satisfying both the conditions of part B - (a) a loop with simple statement and (b) a loop with conditional statement.
Make sure all tests run so 100% coverage of test codes are obtained. In case your tests can not cover 100% coverage, justify the reason why your tests failed to do so and how to mitigate the problem.

Reference no: EM133673724

Questions Cloud

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
Comment out the method calls : It is now your task to write the methods that this program uses. Comment out the method calls until you are ready to use them,

Reviews

Write a Review

Software Engineering Questions & Answers

  Design a wireframe prototype

Design a wireframe prototype to meet the needs of the personas and requirements.

  Difference between re-engineering and process redesign

What is the process of creating design specifications and what are differences between design testing and functional testing?

  CSSE1001 Introduction to Software Engineering Assignment

CSSE1001 Introduction to Software Engineering Assignment Help and Solution, The University of Queensland - Assessment Writing Service

  A staff member or student logs into the system

Provide a staff member or student logs into the system, a list of available courses offered are displayed and a course is selected from the list and all the offered classes for the course are displayed.

  Describe the database concepts of view-based access control

Describe the database concepts of View-based access control, Polyinstantiation, Data warehousing and data mining, and Online Transaction Processing (OLTP)?

  Corporate or organisational culturediscuss why corporate

corporate or organisational culturediscuss why corporate culture is such an important determinant of organisational

  DOT503 DevOps Tools Assignment

DOT503 DevOps Tools Assignment Help and Solution, Torrens University Australia - Assessment Writing Service

  Describe why process is vital part of producing high-quality

Describe why process (in general) is a vital part of producing high-quality. Be sure to use the generic software development lifecycle terminology in your description. (No more than ½ page).

  Prepare a crows foot erd

Prepare a Crows Foot ERD using a specialization hierarchy if appropriate.

  Create the unit testing framework for atm machine

Create the unit testing framework for ATM machine in the style of JUnit Test Infected: with given functionalities like check balance.

  Describes process of migrating existing data to the testing

Testing and Quality Assurance- Develop a data conversion plan that describes the process of migrating existing data to the testing platform.

  Research pcs on a stick on amazon and bhp photo

Research PCs on a stick on amazon and BHP photo and recommend one for the Instructor, Discuss the key specifications you considered in your recommendation.

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