XCTest em execução

Teste

XCTest

XCTestCase

Anatomia de um teste em XCTest

1. Imports

2. Declaração

3. setUp

4. tearDown

Super

5. Test

6. Asserção

Executando

Test Suite 'SomeTestCase' started at 2020-09-07 11:11:28.922
Test Case
'-[SomeTestCase testMetho1]' started.
>>>> METHOD 1 from <ClassTest: 0x600003d784d0>
Test Case
'-[SomeTestCase testMetho1]' passed (0.004 seconds).
Test Case
'-[SomeTestCase testMethod2]' started.
>>>> METHOD 2 from <ClassTest: 0x600003d78590>
Test Case
'-[SomeTestCase testMethod2]' passed (0.000 seconds).
Test Suite
'SomeTestCase' passed at 2020-09-07 11:11:28.929.
Executed 2 tests, with 0 failures (0 unexpected)
in 0.004 (0.007) seconds

Evoluindo o teste

Test Suite 'SomeTestCase' started at 2020-09-07 11:47:23.508
Test Case '-[SomeTestCase testMetho1]' started.
>>>> METHOD 1 from <ClassTest: 0x6000030cc100>
Test Case '-[SomeTestCase testMetho1]' passed (0.004 seconds).
Test Case '-[SomeTestCase testMethod2]' started.
>>>> METHOD 2 from <ClassTest: 0x6000030cc140>
Test Case '-[SomeTestCase testMethod2]' passed (0.000 seconds).
Test Suite 'SomeTestCase' passed at 2020-09-07 11:47:23.515.
Executed 2 tests, with 0 failures (0 unexpected) in 0.005 (0.007) seconds
Documentação da Apple. Citação: Para cada método de teste uma nova instância da classe de testes é alocada.
Documentação da Apple. Citação: Para cada método de teste uma nova instância da classe de testes é alocada.
Apple documentation

Execução completa

Fluxograma de execução XCTest

Indo além

>>>> INIT from <ClassTest: 0x6000016383f0>
>>>> INIT from <ClassTest: 0x600001638430>
Test Suite 'SomeTestCase' started at 2020-09-07 15:01:44.382
Test Case '-[SomeTestCase testMetho1]' started.
>>>> METHOD 1 from <ClassTest: 0x6000016383f0>
Test Case '-[SomeTestCase testMetho1]' passed (0.031 seconds).
Test Case '-[SomeTestCase testMethod2]' started.
>>>> METHOD 2 from <ClassTest: 0x600001638430>
Test Case '-[SomeTestCase testMethod2]' passed (0.000 seconds).
Test Suite 'SomeTestCase' passed at 2020-09-07 15:01:44.429.
Executed 2 tests, with 0 failures (0 unexpected) in 0.031 (0.047) seconds

Observação

Solução

Test Suite 'SomeTestCase' started at 2020-09-07 15:04:24.404
Test Case '-[SomeTestCase testMetho1]' started.
>>>> INIT from <ClassTest: 0x60000027c1e0>
>>>> METHOD 1 from <ClassTest: 0x60000027c1e0>
>>>> DEINIT from <ClassTest: 0x60000027c1e0>
Test Case '-[SomeTestCase testMetho1]' passed (0.005 seconds).
Test Case '-[SomeTestCase testMethod2]' started.
>>>> INIT from <ClassTest: 0x60000027c1e0>
>>>> METHOD 2 from <ClassTest: 0x60000027c1e0>
>>>> DEINIT from <ClassTest: 0x60000027c1e0>
Test Case '-[SomeTestCase testMethod2]' passed (0.000 seconds).
Test Suite 'SomeTestCase' passed at 2020-09-07 15:04:24.411.
Executed 2 tests, with 0 failures (0 unexpected) in 0.005 (0.007) seconds

Conclusão

Indo além

Agradecimentos

iOS Developer — Apple Developer Academy Alumni | Mackenzie. Studying Unit Tests.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store