• Sebastian Ojeda
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

I'm trying to pinpoint an error with a test class using a static variable for a query on Report. Given below test class:

@IsTest
private with sharing class Example_Test_Class {
    private static String testReportName = 'My Test Report';
    private static Report testReport = [SELECT Id FROM Report WHERE Name=:testReportName LIMIT 1];

    @IsTest(SeeAllData=true)
    private static myTestMethod() {
        // Access testReport.Id here
    }
}
Is this valid? I'm not getting any compiler errors but this feels like a possible code smell.