To write a test case, we need to reference the Testing Essentials package. This package is not deployed to sandbox or production environments, which means that any deployment that depends on the test framework will fail. Therefore, we must have a new package for our unit tests. The best way to write tests is to write them as we would write our main code. Therefore, we would add a test project to the same solution as the development project.
Let's say we created a project for a credit check change called ConSalesCreditCheck in the Contoso package. The structure would be similar to the following:
- Solution: ConSalesCreditCheck
- Project: ConSalesCreditCheck (Package Contoso)
- Project: ConSalesCreditCheckTest (Package ContosoTest)
Test packages must always end in Test; normal projects must not. This is because we usually exclude test projects from the package generation on the build server using the name.