Integration testing
What is it?
- Anything bigger than a unit test
What is it?
- Anything bigger than a unit test
- Smaller than a UI test
What is it?
- Anything bigger than a unit test
- Smaller than a UI test
- API level tests
Pains of testing
- Writing tests takes too long - we don't have the time
Pains of testing
- Writing tests takes too long - we don't have the time
- Code changes break the tests
Pains of testing
- Writing tests takes too long - we don't have the time
- Code changes break the tests
- Our code is difficult to test
Pains of testing
- Writing tests takes too long - we don't have the time
- Code changes break the tests
- Our code is difficult to test
- Anything else?
- Big changes are scary
Pains of not testing
- Big changes are scary
- Many production issues
Pains of not testing
- Big changes are scary
- Many production issues
- Code not modular
Pains of not testing
- Big changes are scary
- Many production issues
- Code not modular
- Anything else?
Pains of not testing
Goal of this workshop
- Make testing faster - you'll have the time
Goal of this workshop
- Make testing faster - you'll have the time
- Make tests less coupled - fewer test changes
Goal of this workshop
- Make testing faster - you'll have the time
- Make tests less coupled - fewer test changes
- Test the service - more confidence
Dream
- Refactoring is relaxing
Dream
- Refactoring is relaxing
- Releases are boring
Dream
- Refactoring is relaxing
- Releases are boring
- Code pride
Demo
- Adding an API test to core service
Exercise
- Go to core service repo
- Checkout the branch TestingWorkshop
- Open MyTesla.CoreSvc.IntegrationTests\Controllers\VehicleControllerTests.cs
- Follow the example to add an API test
Demo 2
- Testing a POST request
Exercise Two
- Open this MyTesla.CoreSvc.IntegrationTests\Controllers\OrderControllerTests.cs
- Follow the example to add a happy path
- Add some sad path tests
Pros and cons
CONS
- Slow to run
- Won't isolate issue
- Flakey
PROS
- Quick to write
- Not tied to code
- High confidence
Next steps
- Start writing your own API tests
- Get these running in ATM
Integration Testing
By Tom Dane
Integration Testing
- 336