iosunit-testingarchitecturexctestxctestcase

Are there architectural patterns for Swift Unit Testing?


I wondered if there were architectural patterns, like MVP, MVVM for unit tests in swift.

I know about AAA pattern, but it breaks the logic inside the test method. In all the stuff I've read, the structure of the tests was made the same as the structure of the project itself, and there was no architecture as such.

It looks something like this

Maybe you know some architectures, patterns or approaches that would help to logically break up modular tests into different objects?


Solution

  • XCTest is in the xUnit family of test frameworks. It follows the xUnit architecture to support independent test cases grouped into test suites.

    The most important thing for Swift developers is to learn how to tear things down properly so that test cases remain isolated from each other. See https://qualitycoding.org/xctestcase-teardown/

    For general xUnit design patterns, see http://xunitpatterns.com