Skip to main content
Add detail.
Source Link
David Reed
  • 93.7k
  • 14
  • 90
  • 166

Each test method in a test class is executed in a separate transaction. Although you'd be able to "see" a static variable in each test method in the sense that it would be defined, it'd always be null (unless you write a static initializer, which case you'd just get a new instance) because static variables are reset at transaction boundaries. You can't store and reuse data from one test method to another.

Each test method in a test class is executed in a separate transaction. Although you'd be able to "see" a static variable in each test method in the sense that it would be defined, it'd always be null because static variables are reset at transaction boundaries. You can't store and reuse data from one test method to another.

Each test method in a test class is executed in a separate transaction. Although you'd be able to "see" a static variable in each test method in the sense that it would be defined, it'd always be null (unless you write a static initializer, which case you'd just get a new instance) because static variables are reset at transaction boundaries. You can't store and reuse data from one test method to another.

Source Link
David Reed
  • 93.7k
  • 14
  • 90
  • 166

Each test method in a test class is executed in a separate transaction. Although you'd be able to "see" a static variable in each test method in the sense that it would be defined, it'd always be null because static variables are reset at transaction boundaries. You can't store and reuse data from one test method to another.