Unit testing
is
form the base of the testing pyramid. They test individual components
or functionalities to validate that it works as expected. Since this
is the largest subset
, the unit test should be written as quick as possible. Keep in mind that the number of
the unit test will increase as more feauture are added. This test need to be run in
every time a new feature is added. A good way to build efficent unit test is
to practice
TDD(Test driven development). Since TDD requires a test to be written before any
code, in a result the code ends up simpler, clearer and bug-free.
Integration testing
is the second layer of the test automation pyramid.
The meaning
of using this test is in order to test how this code interacts with other code.
Essentially, these are tests that validate interaction of a piece of code with
external
components such as Databases, external web APIs and the like. Remember they are
slower than Unit tests.
End To End testing
is
at the top of pyramid. This tests do exactly what the name
suggests: test the app is working well from start to finish.
They are at the top because
it takes much time to run them.
75.
What is TDD?
Test Driven Development (TDD
) is a software development practice that focuses on
creating unit test cases before developing the actual code. It is an iterative approach
that combines programming, the creation of unit tests, and refactoring.
76.
What logical blocks does the test consist of (Arrange / Act / Assert)?
*AAA principle is cocept of Unit Testing*
Arrange
: This is the first step of a unit test application. Here we will arrange the test,
in other words we will do the necessary setup of the test. For example, to
perform
the test we need to create an object of the targeted class, if necessary, then we need
to create mock objects and other variable initialization, something like this.
Act
: This is the middle step of a unit step application. In this
step we will execute the
test. In other words we will do the actual unit testing and the result will be obtained
from the test application. Basically we will call the targeted function in this
step using
the object that we created in the previous step.
Assert
: This is the last step of a unit test application. In this step we will check and
verify the returned result with expected results.
77.
What is Moq? Why is it needed?
Mocking is a process used in unit testing when the unit being tested has external
dependencies. The purpose of mocking is to isolate and focus on the code being
tested and not on the behavior or state of external dependencies.
78.
What is the difference between unit tests and integration tests?
Unit testing means testing individual modules of an application in isolation (without
any interaction with dependencies) to confirm that the code is doing things right.
Integration testing means checking if different modules
are working fine when
combined together as a group.
79.
What is IoC?
Inversion of Control (IoC) is a design principle As the name suggests, it is used to
invert different kinds of controls in object-oriented design to achieve loose
coupling. Here, controls refer to any additional responsibilities a class has, other
than its main responsibility. This include control over the flow of an application,
and control over the flow of an object creation or dependent object creation and
binding.
80.
What is Dependency Injection and how does it work?
Do'stlaringiz bilan baham: