At the same time, the dependent-on component (DOC) is a collaborator component that SUT requires to fulfill its duties. In this case, the system under test (SUT) refers to a system being tested for correct operation. In other words, mocking is designed to focus on the code you're trying to test rather than how external dependencies behave.Īs Oleksiy Pylypenko, the creator of MockK, states: "The main point to have stubs or mocks is to isolate testing one component, which is called System Under Test, from their Dependent-On Components." The term "mocking" refers to the technique of programming your testing objects with expectations that specify the calls they're supposed to receive. Now, let's start with some critical groundwork. If that's not the case, I advise you to explore this article on making your first Kotlin app. And in this article, we will explore how to use MockK to create a simple test in Kotlin by mocking some of the objects and methods in the project.įor the purpose of brevity, I will assume that you are already familiar with testing frameworks like JUnit and the concepts that makeup the TDD methodology. MockK is, undeniably, one of the most widely adopted mocking tools for Kotlin. There are several libraries that offer you simple and versatile solutions to this requirement, with MockK among the most popular. One of the most complicated aspects of building robust test suites is ensuring you can mock the data your code needs and handles.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |