Use @IsTest instead of testMethod when creating new unit test classes

Issue #930 resolved
Kevin Vizcarra created an issue

When creating a new unit test class, the empty test method has the testMethod modifier. testMethod is deprecated and @IsTest should be used instead.

FWIW, the ApexUnitTest template used by sfdx uses @IsTest.

Comments (2)

  1. Scott Wells repo owner

    Kevin, that's how it has been for a while. Here's the template that's bundled with IC1 and IC2:

    #parse("Apex File Header.cls")
    
    @IsTest
    private class ${NAME}
    {
        @IsTest
        static void testBehavior()
        {
        }
    }
    

    Can you look in Settings>Editor>File and Code Templates and see if Apex Unit Test Class is blue? If so, select it and click the Reset to Default toolbar button. Or, if you've customized it yourself and want to retain those customizations, you can make that change.

  2. Scott Wells repo owner

    I'm going to resolve this since it's already that way, but if you find that it's still showing testMethod instead of @IsTest in yours and it's not coming up as modified, please let me know.

  3. Log in to comment