
Basics of Automated Testing
Most coders just code their apps and do manual testing before publishing to QA. So, what is manual testing? It is a process where you test your function by launching your application on a browser. Perhaps you have to login or maybe you have to navigate with few clicks to get the page where the function is used. Next, you have to fill in the form, submit it, and see the results of the function on the screen.
You have to repeat all the steps each time with different values in the form and this workflow to test the function may take several minutes every time. This is very time consuming. This is the only application function you will test. In real applications, you have dozens or hundreds of functions. As your application grows in complexity the time required to manually test all the different bits and pieces increases exponentially. This is where automated testing comes into the scenario to rescue us from all the hard work.
With automated testing, you write code and check the testing functions with different inputs. You also verify the functions to learn the right and wrong outputs. This enables you to rerun these tests every time you change your code or commit your code to repository and before deploying the application. With this approach, you can test all the functions in less than a second.
You can write hundreds or thousands of automated tests for various parts of your application and run them all in just a few seconds. There are frameworks available like MSTest, xUnit, NUnit, etc. for automated testing to write the test codes once and execute them whenever it is required to test the code without running the app. By definition, we can say automated testing is the practice of writing code to test our code and run these tests in an automated fashion.
Benefits of Automated Testing
- The most important benefit is that we can catch the bugs before deploying the application. This is extremely important because it allows deployment of the application with more confidence. Have you been a situation at work when you deployed an application and thought everything is working only to get a call that one of the major functions of app is not working? You have to go back to office and thought that it would be a quick fix. You ended up staying there until midnight. That’s why you should write test to reduce number of bugs that will go in the production.
- Automated testing also allows you to refactor your code with confidence. Refactoring means changing the structure of code without changing its functionality. When you don’t have automated tests every time you refactor your code, you have to manually test every part of the application that could be affected by your refactoring. This can be very painful. Every time you refactor code, run automated tests to make sure you didn’t break anything that was previously working.
- Another benefit of automated testing is that it helps you focus more on quality of the methods you are writing. You can make sure that every method works with different inputs under varying circumstances.
Types of Testing
Unit Test:
In unit testing, you test a unit of an application without external dependencies such as files, database, message queue, web services, and so on. They are cheap to write and are executed fast. It is possible to run hundreds of unit tests in just a few seconds. You can be sure that each building block is working as expected, however you are not testing these class components with external dependencies. You can’t get a lot of confidence in reliability of your application and this is when integration testing comes to the rescue.
Integration Testing:
In an integration test, you test a class or components with its external dependencies. It tests integration of your application code with concrete dependencies like file, databases, and more. These tests take longer to execute because they often involve reading or writing but they give more confidence in the health of your application.

End-to-End Test:
In end to end testing, the test drives an app through its user interface and there are tools for creating end to end test. One popular tool is Selenium which allows us to record interaction of the user with application and play back to check if the application is delivering the right results.
These tests give a great amount of confidence about the health of your app, but they have two big problems:
- They are slow because they repeatedly launch the app and test it through UI. Every test is going to launch the app, potentially login in the app, navigate to the internal page, and then submit form and expect the required result.
- They are brutal because small changes in app or UI can easily break this test.
So, what kind of test you will like to write in the app?
It depends upon the requirement and kind of application you are building. Most of the tests should be in the unit test category because they are easy to write and execute quickly, but they don’t give much confidence. You should have a bunch of integration tests that test integrations of app code with external dependencies. These tests provide many advantages of end-to-end tests but without the complexity of dealing with UI. Finally, you should write very few end-to-end tests for the key functions of the app, but you should not test edge cases with these end-to-end tests. You should only test happy path and leave the edge case to unit testing.
If you are interested in automated testing for your software idea, contact us at Dignitas Digital in Philadelphia.
Read Next: 20 Points Mobile Application Testing Checklist