Answer the question
In order to leave comments, you need to log in
Choosing an isolation level for each module
Hello.
I'm currently learning unit testing and I have a question about the correct isolation level for each module.
Let's imagine that we have two classes in JS that together represent the same component or layer:
function HighClass() {
this.lowClass = new lowClass();
}
function LowClass() {
this.db = new SomeDB.Connecton();
}
Answer the question
In order to leave comments, you need to log in
Second option. As a bonus, get a code that adheres to the Single Responsibility Principle more strictly.
correctness, like any evaluative concept, depends on the context. in your case - from the purposes of testing. unit testing and unit testing are not the same thing. :)
with the help of unit testing, the correctness of the application elements is checked separately. it is important that the tested aspects do not overlap (the same thing is not tested by different tests and the tests do not fall if something breaks in a completely different place). logically, this is possible only at the level of atomic elements, which in OOP are classes and methods. and all that is higher will inevitably give correlations associated with the system. for example, if a LowClass implementation breaks, it should not affect the HighClass unit tests—the LowClass unit tests will report such a break to you. so the correct strategy would be 2.
integration tests are used to test the "assembly" system. they are also very necessary - after all, it is important not only to assemble from proven parts, but also to connect them correctly - here you will use strategy 1.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question