A
Size: a a a
A
ОН
А
A
M
How to write a new test
last modified by Oleg Neumyvakin on Feb 16, 2019
New test produce new maintenance efforts
When you are going to create a new test first of all you are going to create new maintenance efforts for you and your team.
And when you are writing test code only thought you should keep in mind is how to reduce maintenance cost of this test.
Logs
By default, test should log everything in verbose mode or even trace mode, even results of success operations have to be logged.
Flat code
Test code have to be flat, with minimum or even no inheritance in behavior.
Speed and Memory
Test execution have to be fast and require as minimum memory as possible. If something can be executed asynchronously or parallel it should be executed asynchronously or parallel.
Fail fast
Test should fail as early as possible. At first test should prepare most of the fragile and unstable required data or entities.
Split errors of infrastructure, network, product from test fails
Test can fail because of environment issues like infrastructure services, network is broken by default, product behavior is unstable.
It's a good practice to try classify and split errors of environment from real test failed checks.
Atomic
Test have to be atomic. It shouldn't depend or rely of data created by another test and shouldn't rely of order of execution.
Checks before and after
Test have to check environment for existing of entities it going to create.
If final check is some list is not empty then first check is this list is empty before execution of any actions.
If final check is existence of file or directory then first check is that this file or directory is not exists.
A
МБ
EK
А
EK
OS
ОН
MM
MM
MM
MM
KG
ОП
A
A