It's All Writing.

Writing makes you happy.

How to get data which made in @testSetup method at Apex

Environment

  • Apex

Prerequisites

We cannot access variables which made in @testSetup method at @isTest method.
The example is shown as below.

gist.github.com

Solution

The solution is to select the test data by using SOQL again.

gist.github.com

Reference

tyoshikawa1106.hatenablog.com