softwareTesting/Lab5/DependencyPractical.docx In the previous practicals we used the Junit unit test engine. However the last practical uncovered the issue where one method calls another method i.e....

1 answer below »
for the first file, there is two labs in it the lab5 is to be done first then the lab6 is t be done afterwards, there also supporting screenshots to go with it
for the second file which is attached all information on it is on the sheet





softwareTesting/Lab5/DependencyPractical.docx In the previous practicals we used the Junit unit test engine. However the last practical uncovered the issue where one method calls another method i.e. CompareArrays method calls the Equal method. In situations like this we won’t know if a test failure relates to the code in CompareArrarys or the code in the Equal method. We need a way to test the code in compareArrays in isolation of the code in Equal method. We can say that CompareArray method depends on the Equal method. Properties of Good Unit Tests: Automated, repeatable, Easy to implement, Relevant tomorrow, anyone should be able to run it at the push of a button, run quickly, be consistent in its results, have full control of the unit under test, be fully isolated, easy to detect why it fails, be readable, be reliability and trustworthy. It must be possible to run unit tests in any order without any configuration or setup, otherwise we can’t automate running our unit tests as regression tests. Dependencies in Code - Code in commercial code bases typically has lots of dependencies. This is necessary and is part of the complexity of working as an IT professional. A dependency may be where one piece of code calls another as we have seen, or code could depend on accessing information in a file or database, network connection, date time etc. In fact there are any amount of dependencies our code needs to function and over which we have no direct control. For example a lodgeSalaries method in a payroll system may need to check that it is five days before the last day of the month before actually lodging salaries into employees accounts, so guaranteeing employees are paid before the end of each month. We can’t simply wait until it’s exactly five days to the end of the month to test the lodgeSalaries method to ensure the salaries are lodged as required. We could change the system time on the computer we are using to be 5 days before the end of the month and then test the pay salaries method, but this is configuration. Looking at the properties of good unit tests this would not be allowed. These next practicals examine how dependencies are handled. Cross-cutting concerns The majority of applications will contain common functionality that spans layers and tiers. This functionality typically supports operations such as authentication, logging etc. It’s crosscutting because it affects the entire application and we want it centralized in one location in the code base. LogFileAnalyser Below is the sample code for a simple LogfileAnalyser class. This code would be part of a larger log monitoring application. Monitored production systems produce log files and LogfileAnalyser analyses them. The production system produces a log file detailing how it is operating. This is typical of live systems which produce information on how they are running which can be monitored by IT to ensure everything is operating correctly. The LogFileAnalyser has code for the current business logic for dealing with operation and failure of a monitored production system. This logic is as follows: 1. Checks that the Log file has a valid extension i.e. ends with .log. 2. Checks if the monitored system crashed i.e. it opens and reads information from the log file to determine this. 3. Checks if the monitored system ran normally i.e. it opens and reads information from the log file to determine this. 1. Create the LogAnalyser project Create a new Java project and make it a Java Class Library Click next and make the Project Name LogFileAnalyser and click Finish. Create a package named CrossCutting, do this by right clicking the project and click New Java Package, name it CrossCutting Add a class called LogFileAnalyser, do this by right clicking the CrossCutting package in the Projects windows and click New Java class and name it LogFileAnalyser and click finish. Open LogFileAnalyser.java file by double clicking it in the Project window and replace the generated code with the code below: package CrossCutting; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import javax.swing.filechooser.FileSystemView; public class LogFileAnalyser { private Boolean lastLogFileStatus=null; private String path = FileSystemView.getFileSystemView().getDefaultDirectory().getPath()+ "\\Logs\\"; public Boolean AnalyseLogFile(String fileName) { // First piece of business logic is to check that the Logfile has a valid extension. Unit tests need to test this. if(!fileName.endsWith(".log")) { return false; //LogFile extension is invalid } // Next open the Log file and read the log status String readMeText; String status = null; try { System.out.println("Reading actual log file on disk --> You should not be seeing this from Unit tests"); File file = new File(path+fileName); BufferedReader br = new BufferedReader(new FileReader(file)); readMeText = br.readLine(); if (readMeText.contains("Exception")) { status= "Monitored system crashed"; //As the word Exception was in the log file } else //anything else in the log is a normal log { status= "Normal Log"; } br.close(); file.delete(); // Delete the log file as I don't want to process it again } catch (Exception e) { e.printStackTrace(); System.out.println("You must pick Option 1. or Option 2 before you pick Option 3. Run the Simulator again!\n"); System.exit(0); } // The status is read from the logFile. Next is the business logic which is to be tested by unit tests if(status=="Normal Log") // This is business logic which is to be tested by unit tests { lastLogFileStatus=true; return true; } else if(status=="Monitored system crashed") // This is business logic which is to be tested by unit tests { lastLogFileStatus=false; return false; } else return false; //Anything else in the Log file indicates a problem } } The code above is in a class library project ie .JAR so you can’t run it directly, you need to create a client application to run it. 2. Create the LogFileAnalyserJavaApplicationClient application Create a new Java project and make it a Java application, and click next Click next and make the Project Name LogFileAnalyserJavaApplicationClient and click Finish. Create a package named ClientCode, do this by right clicking the project and click New Java Package, name it ClientCode Open LogFileAnalyserJavaApplicationClient.java file by double clicking it in the Project window and replace the generated code with the code below: package ClientCode; import CrossCutting.LogFileAnalyser; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.Scanner; import javax.swing.filechooser.FileSystemView; /** * * @author Brendan.Watson */ public class LogFileAnalyserJavaApplicationClient { /** * @param args the command line arguments */ public static void main(String[] args) throws FileNotFoundException { System.out.println( " ----> This Simulator allows test drive of the LogFileAnalyser cross cutting component. <---- \n"); system.out.println( " this simulator provides functionality to:"); system.out.println( " a. run the cross cutting logfileanalyser isvalidlogfilename method."); system.out.println( " the logfileanalyser has code for the current business logic for dealing with operation and failure of a monitored production system"); system.out.println( " the production system produces a log file detailing how it is operating. this is typical of live systems which produce information on how they"); system.out.println( " are running which can be monitored by it to ensure everything is operating correctly"); system.out.println( " b. produce simple log files"); system.out.println( " when you use this simulator to produce a log file you are mimicking running a production system which would provide useful functionality for the "); system.out.println( " business and also produce a log file so that it can know what is going on with the system"); system.out.println( " \n"); system.out.println( "choose from these choices, you must click \n");="" system.out.println(="" "="" this="" simulator="" provides="" functionality="" to:");="" system.out.println(="" "="" a.="" run="" the="" cross="" cutting="" logfileanalyser="" isvalidlogfilename="" method.");="" system.out.println(="" "="" the="" logfileanalyser="" has="" code="" for="" the="" current="" business="" logic="" for="" dealing="" with="" operation="" and="" failure="" of="" a="" monitored="" production="" system");="" system.out.println(="" "="" the="" production="" system="" produces="" a="" log="" file="" detailing="" how="" it="" is="" operating.="" this="" is="" typical="" of="" live="" systems="" which="" produce="" information="" on="" how="" they");="" system.out.println(="" "="" are="" running="" which="" can="" be="" monitored="" by="" it="" to="" ensure="" everything="" is="" operating="" correctly");="" system.out.println(="" "="" b.="" produce="" simple="" log="" files");="" system.out.println(="" "="" when="" you="" use="" this="" simulator="" to="" produce="" a="" log="" file="" you="" are="" mimicking="" running="" a="" production="" system="" which="" would="" provide="" useful="" functionality="" for="" the="" ");="" system.out.println(="" "="" business="" and="" also="" produce="" a="" log="" file="" so="" that="" it="" can="" know="" what="" is="" going="" on="" with="" the="" system");="" system.out.println(="" "="" \n");="" system.out.println(="" "choose="" from="" these="" choices,="" you="" must="">
Answered 12 days AfterMar 10, 2021

Answer To: softwareTesting/Lab5/DependencyPractical.docx In the previous practicals we used the Junit unit test...

Mamta answered on Mar 23 2021
143 Votes
Question 1
White Box Testing
Whitebox testing looks into the applications being evaluated and integrates the detail into the testing process. It i
s a technique for evaluating and validating the processes, internal structures, artefacts, and elements of a software programme. It is also known as structural or code-based checking.
1. Developers conduct white box research. This necessitates an understanding of software's internal coding.
2. White box monitoring is associated with the program's execution. The aim of this test is to run multiple programming constructs, not just the data structures used by the programme, rather than any of the different input and output conditions. This is referred to as a structural evaluation.
3. White box testing is most often used for low-level testing. Unit and integration tests are two types of tests.
4. White box research necessitates deployment expertise.
Black Box Testing
The following programme is tested as a black box without understanding what's inside. The tests include use of a software interface to ensure that it performs as intended, rather than being solely reliant on software requirements and specifications.
1. A specialised research team does Blackbox testing. This does not necessitate a detailed interpretation of the application's internal coding. Without some prior experience of device internal coding, test the programme against its functionality.
2. The layout of the software is not taken into account by...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here