Replies: 3 comments 4 replies
-
Hi @Daissy538 , there is not one unique way to do it. Every way has positive things and drawbacks. If you want to have one call to the SUT per test method, there will be the need to setup the system to the point where it is possible to test what you want. To learn and get used to TDD, this is the best approach. |
Beta Was this translation helpful? Give feedback.
-
I have been using an approach where I prepare, e.g. an object repository to hold relevant data before calling the method under test. // Arrange
service.repository.insert([
// ...what you need
]);
// Act
const result = service.workOnIt();
// Assert
expect(result).toBe(/* ... */); This makes testing more convenient as I don't have to bloat the Arrange part of the test body and I have already satisfyingly covered the other methods that I would have used there. |
Beta Was this translation helpful? Give feedback.
-
Thanks @nikoheikkila and @marciovmartins, My next learning step will be to learn more about different architectures and then try them out within a new branch of my own project. I understand that Unit Testing and architecture are influencing each other more than I realized. Thanks for pointing it out in my code! |
Beta Was this translation helpful? Give feedback.
-
Hey everyone,
@valentinacupac.
I have a question that came to my mind, when watching the mob https://www.youtube.com/watch?v=kyG_ljVF3cA&ab_channel=TechExcellence
I thought that testing business logic in isolation/unit meant that you only use one function of the SUT in that Unit Test.
However, in the example, Take() was called multiple times as an arrange, followed by the ACT GetCurrentPlayer(). (https://youtu.be/kyG_ljVF3cA?t=3498)
In this case, does isolation/unit mean a set of actions that reassemble a business flow?
Can an ACT be more than testing one function, that has a busness flow behind it?
And if true, should the individual functions also be tested separately?
Greetings!
Beta Was this translation helpful? Give feedback.
All reactions