I want to mock the behavior of the value object.

Asked 1 years ago, Updated 1 years ago, 62 views

When I was going to write the process of converting Markdown to Html, I prepared Markdown and Html classes as value objects.

And the Html class writes about how Markdown is instantiated as an argument and converted to Html.

And this Html is called in Application Service.
What should I do when I write the Application Service test to mock the conversion process?

In the first place, you don't use mock...?
Regardless of language or method, I was wondering what everyone was doing, so I asked.

Thank you for your cooperation.

domain-driven-design

2022-09-30 20:23

1 Answers

What should I do when I write the Application Service test to mock the conversion process?

If you want to mock the process,
I think it is possible by mocking the method in the mock library, which is available in various programming languages.

In the first place, you don't use mock...?

If it's a unit test, "In the Html class, we write the process of converting Markdown to Html when instantiating it as an argument," so I feel like I can write the test without using mock.
I think mock is often used when you have to touch actual external resources (ex.DB access, API access, real-world environmental access).


2022-09-30 20:23

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.