What is test utility class in Salesforce?

What is test utility class in Salesforce?

Test utility classes contain methods that can be called by test methods to perform useful tasks, such as setting up test data. Test utility classes are excluded from the org’s code size limit.

How do I learn to write unit tests?

  1. 13 Tips for Writing Useful Unit Tests.
  2. Test One Thing at a Time in Isolation.
  3. Follow the AAA Rule: Arrange, Act, Assert.
  4. Write Simple “Fastball-Down-the-Middle” Tests First.
  5. Test Across Boundaries.
  6. If You Can, Test the Entire Spectrum.
  7. If Possible, Cover Every Code Path.
  8. Write Tests That Reveal a Bug, Then Fix It.

How are unit tests used in Test Driven Development?

With test driven development, you create the unit tests before you write the code, so you use the unit tests as both design documentation and functional specifications. Test Explorer can also run third-party and open source unit test frameworks that have implemented Test Explorer add-on interfaces.

How to write unit tests for a method under test?

The AAA (Arrange, Act, Assert) pattern is a common way of writing unit tests for a method under test. The Arrange section of a unit test method initializes objects and sets the value of the data that is passed to the method under test. The Act section invokes the method under test with the arranged parameters.

Which is an example of a unit test project?

A unit test project usually mirrors the structure of a single code project. In the MyBank example, you add two unit test projects named AccountsTests and BankDbTests to the MyBanks solution. The test project names are arbitrary, but adopting a standard naming convention is a good idea.

What are the basic building blocks of unit testing?

The basic building blocks of unit testing are test cases — single scenarios that must be set up and checked for correctness. In unittest , test cases are represented by unittest.TestCase instances. To make your own test cases you must write subclasses of TestCase or use FunctionTestCase.