Fixed – “Compile Error: Type is not visible: test”
“Error: Compile Error: Type is not visible: test at line…” was bugging one of my peer developer for a while. For us, it was coming at a line in the source code where Test.startTest() call is made, though it can come at any other use of any method from the “Test” class.
At first, we thought that the API version of the class was not the latest, but then we recalled that it was not Test.isRunningTest(), but Test.startTest() that has been failing, which has existed for the last 3+ years. Then what could be the problem?
The problem came because some developer created an apex class named “Test.cls”, it’s unfortunate that this is allowed, but it is. This messed up the Apex runtime, and on some occasions, it worked but failed in most of the places where we are referring to the SYSTEM Test class.
We learned this lesson the hard way by wasting a lot of time. Posting this to save time for other developers who will Google for this strange issue.