When (if ever) will testmethod fail to compile?

I just recently learned from the Apex Developer Guide documentation on the IsTest Annotation:

The testMethod keyword is now deprecated. Use the @isTest annotation on classes and methods instead.

Are there API Versions where use of this keyword will cause a compile fail? If not, do we know if/when that is coming?

Answer

The testMethod keyword is now deprecated. Use the @isTest annotation on classes and methods instead.

I’ve been telling people not to use this for ages; @isTest is not just a testMethod replacement, it allows us to specify things like parallel testing boundaries and database isolation.

Are there API Versions where use of this keyword will cause a compile fail?

Not at this time. There’s no specific announcement at this time, so it’s probably at least a year out (v45.0 or later). Besides, if they tie it to a version, then it’ll be like database isolation and unit test method isolation (v27.0/v28.0). Older classes will work for some time (probably at least 3-5 years), but newer classes will compile-fail if you specify a newer version. Note that the actual dates are just examples, since we don’t have a formal time line.

If not, do we know if/when that is coming?

It may never come. The bulk keyword, introduced in the earliest days of Apex Code, is still supported, despite being vestigial for about a decade now. Most likely, given they’ve marked it as deprecated, it’ll be version-locked at some point, but I doubt it will ever fully go away, as long as people are using it, which may well take a decade or longer.

Attribution
Source : Link , Question Author : Adrian Larson , Answer Author : sfdcfox

Leave a Comment