SunPoint IT Solutions



Introduction to tests

There are many benefits to writing modular tests: they help with regression, provide documentation, and promote good code structure. But they have difficult and unreliable modular tests, which can have a negative effect on the code. Let`s get acquainted with the basics of testing. Modular testing, or unit testing - a process in programming that allows you to check the correctness of individual modules of the program source code. The idea is to write tests for each non-trivial function or method. And this allows you to quickly check whether the next change in the code led to regression, ie to the appearance of errors in already tested places of the program, which greatly facilitates the detection and elimination of such errors. The modular test allows you to test individual software components or methods, also called "unit of work". Modular tests should check only the code that can be modified by a particular developer. They do not affect aspects of the infrastructure. The infrastructure here includes any interaction with databases, file systems and network resources. The integration test differs from the modular one in that it allows you to check the joint work of two or more software components, ie the integration of these components. These tests more broadly affect the system being tested, while modular tests focus on individual components. Integration tests often contain some elements of infrastructure interaction. The load test determines whether the system can handle a given load level, such as withstanding a certain number of simultaneous user connections to an application and responding quickly to interaction requests. Main advantages: Less time to perform functional tests. Functional tests require a lot of resources. Typically, you have to open the application and perform a series of actions to check the expected behavior. Test engineers do not always know what these actions are, and they have to turn to experts in this field. The testing itself can take a few seconds if these are normal changes, or a few minutes for larger changes. Finally, this process must be repeated for each change made to the system. Modular tests, on the other hand, take milliseconds, are performed at the touch of a button and do not necessarily require knowledge of the entire system. The success of the test depends on the means of performing the test, not on the user. Regression protection. Regression defects are introduced when making changes to the application. Quite often, test engineers test not only a new feature, but also pre-existing features to verify that those features are still working properly. With modular testing, you can run the entire set of tests after each build or even after changing a line of code. This gives you confidence that your new code has not violated existing functionality. Documentation is in progress. It is not always obvious what a particular method does or how it behaves with certain input data. You may ask yourself: how will the method behave if I pass it a blank line? And the value of NULL? If you have a set of unit tests with clear names, each test will be able to clearly explain what the output will be for certain inputs. Also, he will be able to check that it really works. Less related code. If the code is closely related, it is ill-suited for modular testing. Without creating modular tests for the code, this binding may be less obvious. When you write tests for code, you naturally share it, otherwise it will be harder to test. Characteristics of a good modular test. Fast - Well-designed projects can have thousands of modular tests. Modular tests must be executed very quickly. Isolated - Modular tests are standalone, can be performed in isolation and do not have dependencies on external factors such as file system or database. Repetitive - Modular test runs must have consistent results, ie always return the same result if you do not make any changes between runs. Unambiguous - The test should automatically determine whether it was passed or not, without participation user. Appropriate - The time to write a unit test should not significantly exceed the time to write tested code. If you think that testing code takes too long compared to writing code, think of a structure that is more suitable for testing. Popular .NET frameworks xUnit is a free, open source modular testing tool for .NET. This is the latest technology for modular testing of .NET applications, created by the first developer of NUnit v2. supports ReSharper, CodeRush, TestDriven.NET and Xamarin. This is a .NET Foundation project, so it works according to their code of conduct. NUnit is a modular testing platform for all .NET languages. It was originally ported from JUnit, and the current working release has been thoroughly redesigned with the addition of new features and a wide range of supported .NET platforms. This is a .NET Foundation project. MSTest is Microsoft`s test platform for all .NET languages. It supports extensions and work with .NET CLI and Visual Studio. Test-Driven Development (CTR), Test-Based Development is a software development technology that uses short itegrations of development, beginning with the pre-writing of tests that identify necessary improvements or new features. Each integration aims to develop code that will pass these tests. Finally, the programmer or group refines the code to agree on the changes. One of the key points of TDD is that preparing tests before writing the code itself speeds up the process of making changes. It is worth noting that test-driven development is a methodology for software development, not testing it.