Automated Testing Using Scripting CEN 4072

Automated Testing Using Scripting CEN 4072

1 Automated Testing Using Scripting CEN 4072 - Software Testing Team Essay: Fall 2020 Team Tyler ABSTRACT In the process of developing a software, testing is one of the most important aspects in order for a project to be successfully deployed without major bugs. However, testing becomes extremely hard when working with time constraints. The process of debugging manually could take as much time as the process to develop a functionality of the software. Therefore, implementing automated testing through scripting improves the time lapse for debugging and increases the accuracy in finding more errors due to its fastest capabilities to test the code. In addition, automated testing provides the programmer with the ability to create specific test cases that better suits the software being developed. Using techniques such as breaking the functionality of the project into many modules the developer can locate issues in a more effective way. Therefore, automated testing through scripts can be considered a tool that developers should implement into their testing process in order to facilitate the task and increase the chances of finding bugs. KEYWORDS Scripting, Testing, Automatization, Framework, Software. INTRODUCTION Test scripts are the basic building blocks of automation. A test script is written in a scripting language like Perl, Python, Ruby, etc. and contains a series of instructions that execute a test case and report the results. These instructions may behave reactively to the data output from the program under test or the script can simply utilize a loop to repeat the same instructions many times with different sets of data. How complex the script is depends entirely on the project at hand and what the developer wants to accomplish with each script. To help a developer make scripts for use in automated software testing, there are several techniques, called frameworks, that have been widely adopted. These include linear scripting, structured and shared, data driven, keyword driven, and several more. 2 BENEFITS OF USING SCRIPTS IN DEBUGGING In order to achieve a software that runs smoothly and to reduce the chances of crashes and bugs, the implementation of scripts for debugging is essential. In comparison with manual debugging, scripts allow programmers to use automated testing in order to reduce the time ths tedious task usually takes. Debugging manually is a very slow and stressful process. Sometimes, this can result in a series of tests that get skipped or ignored. Scripts help to make the testing process less painful. They allow programs to create the cases in which each function of the program should pass and return a successful result. When using test cases the software is broken down into modules in order to create a flag where the errors are occurring. Programmers can directly reach that functionality and identify the bug faster. A good example of this strategy is already applied by many programers when testing a software and getting wrong or unexpected answers. The strategy consists of commenting out lines of the code and modifying it in order to identify the issue or what is breaking the execution of the program. In the case of automated testing, it will check for which step the execution results are not the expected for that particular module of the software. Automated testing and debugging go hand in hand in that automated testing is done to find bugs and errors and debugging is performed to fix the bugs. While they both focus on bugs, testing ends with bugs and debugging begins with them. The automated part of testing is optional, but it is very helpful when a test needs to be performed many times. Unfortunately, bugs are more elusive and while there may be situations in which we encounter the same bug over and over, it is still not yet practical to automate debugging. Additionally, there are times when automated testing fails to find a bug, despite this being its main purpose. If an error or a bug is outside of the framework under which the automated test checks things, then it can go unnoticed and later cause a problem. Manual testing however can be much more exploratory and uncover bugs that automated testing would miss. For this reason, manual testing is unlikely to go away anytime soon and, for many projects, is considered essential. AUTOMATED TESTING VS MANUAL TESTING There are two types of testing used when testing a system, automated and manual. They both serve different purposes but automated testing is the more convenient and powerful one for many situations. Automated testing is performed by a software tool that is prewritten and will perform certain actions to make sure the software runs properly, whereas manual testing is performed by a human from scratch, nothing is prewritten and every testing tool is to be implemented right then and there. By seeing their differences, we could see why one might opt for automated; as it is more convenient, faster, and more accurate. Manual testing could not only take much more time, but it is very prone to human errors along the way. Also, as automated testing avoids things like human errors, it can save money for the developer because it avoids the need to repeat any tests for the code. The more you are obliged to repeat a certain test - which manual testers often do - the more time and money it 3 would cost, which is something we try to stay away from. Manual testing cannot test thousands of codes for the system as it is physically near impossible, and even if it weren't, it would take time that the company or developer cannot afford, whereas automated testing could easily do this as well as share those automated test codes with other developers. However, there are some limitations to having automated testing, those of which where the tester has to be very proficient in using such testing tools because any complications or errors may lead to redoing the whole test script, which in result is very costly and defeats the purpose of automated testing. Another disadvantage would be if there are too many screens to be tested, major maintenance issues would prevail as it is difficult to keep track of bigger screens. All in all, the pros to automated testing are shown to be superior to manual testing, and the cons are very limited compared to manual testing. This comes to show us how important and advantageous automated testing is in the world of testing scripts and to developers everywhere. FEATURES OF THE SCRIPT LANGUAGE Pytest is a widely used script language that can be used to create automated tests. To use it, one should start by creating a .py file and importing pytest and the files which we want to test. Additionally, if the test file contains some value fetched from a database, you also need to import SQlite3. The next step is to create a test class and define some methods in the class. In these methods, we can get a value by calling a function from the file imported and using an assert method to verify the output value. There are several assert methods available to use such as assertEqual(a,b), assertTrue(x), assertIs(a,b), etc. After these steps, we can run our testing code. The above is an example for testing output. If the return value is equal to the assert value, the output will show PASSED. The percentage shows the process of testing. 4 If the return value is not equal to the assert value, the output shows Assertion Failed. If all the tests passed, the output shows how many tests passed and the processing duration time. After testing, we have to maintain the automation test. If there are new functionalities added to the files or some functionalities have changed, the automated test will need to be updated to adequately test the new changes. Further, maintenance is executed when new automation scripts are added and needs to be reviewed in order to improve the effectiveness of automated tests. ESSENTIAL TOOLS AND FUNCTIONS Automated testing has what is known as frameworks. These frameworks are like scaffolding to build your automated tests on. They provide a set of rules, standards, protocols, and guidelines that can be leveraged to more efficiently make automated tests for whatever software project a developer is working on. Test automation frameworks help significantly when working in a team, as the team can decide on a framework that best suits the project needs. This allows for better understandability, teamwork, maintenance, and easy reporting. Having a framework also helps if someone wants to come back to the code and reuse it. By knowing which framework was used, they can more easily understand how it works and how they can reuse it. An example of one of these automated testing frameworks is the data driven testing framework. It is oriented towards the situation where a tester needs to test the same functionality 5 many times with different sets of data as it helps the user to separate the test data and the test script logic. The framework looks like this: Software Testing Fundamentals DETAILED APPLICATION EXAMPLE Scripting plays a tremendous role in software testing; using scripts can be very beneficial compared to other ways. To learn more about the benefits of how scripting can improve software testing and debugging, let’s take a look at an example using Python. Below is a simple program in Python named Temperature.py. 6 The program Temperature.py asks the user to enter a temperature. Then, the user is asked what they want to convert the temperature to (Celsius or Fahrenheit). Finally, the program prints out what the temperature was converted to, as shown in the two examples below.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    10 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us