Test should follow three steps:
Setup
Method
Validation/Assertion
Avoid implementation of external dependencies in unit tests.
Using things like dependency injection (and shallow-mocking the dependencies), you can avoid relying on the actual implementations to run properly for the test to pass.
// external dependencies and its implementation tested import ( someExternalFunction ) func testTightCoupling(someParam: string) boolean { testValue := someParam // calling actual implementation (bad) someExternalFunction(testValue); // assertion } // shallow dependencies using mock return value const mockedServiceMethod = mock(someExternalFunction) func testLooseCoupling() boolean { testValue := someParam // calling mocked implementation mockedServiceMethod(testValue) }