Today I experienced an error that I have never experienced before. When I go into my developer console on salesforce and run unit tests for, supposedly, all of my code, I get my typical high percentage overall coverage as a result. The reason I was running a complete unit test is because I added one simple class to a package, which had a corresponding test class that covered the code entirely.
I had previously released the package with a passing score, which I assume was significantly higher than 75%. Yet, today, when I was going to publish the package after seeing the overall coverage was high, I kept getting the error:
Upload Failed Average test coverage across all Apex Classes and Triggers is 73%, at least 75% test coverage is required.
Never before had my code been passing all of the tests and obtaining a passing score on the overall code coverage but failed to publish.
Currently I am blaming DML errors. Some of the test classes, which I had written prior to gaining some knowledge about test classes, used (seeAllData=true). Sometimes (very rarely) my unit tests would result in a failure of a large class because of a locked row exception. I'm guessing that because some test classes seeAllData, and all test classes are inserting similar records, that is why I get this error.
Here is my question: What is the scope/accessibility (unsure of the word) of test methods?
What I mean is, if one test method inserts ExampleObject__c and another test method inserts a different ExampleObject__c (whether ExampleObject__c is an object OR custom settings) (asynchronous) could those objects possibly interact?
Is the reason for my locked row errors because two test methods are inserting the same custom setting?
If so, how do you go about making sure that the test class has the appropriate setting data but does not seeAllData/lock rows for other test methods?