+ Start a Discussion
jhartfieldjhartfield 

Getting view state error when running all unit tests

When I try to run all the unit tests via the 'Run All Tests' button found in Develop->Apex Classes, I have started getting the following message:

 

Maximum view state size limit (128K) exceeded. Actual viewstate size for this page was 150.625K

 

We have a pretty large ORG set up, so I'm sure it's because the system log has simply gotten too huge.  When we run all the unit tests by using the Eclipse IDE, the tests complete just fine, except we don't get a snapshot of the overall code coverage.  We just get code coverage on a class by class basis.

 

We want to be able to see where our overall code coverage is at.  Is there any other way to do this other than through the web interface?  Or, is there any way to make the unit tests less verbose through the web interface to reduce the size of the view state?

Best Answer chosen by Admin (Salesforce Developers) 
jhartfieldjhartfield

It doesn't look like there is a good easy solution to this, so I made a little .NET application using the Apex web API to run the tests using the 'runTests' method.  From the test results I was able to figure out my code coverage by doing some quick math on the CodeCoverageResult.numLocations and CodeCoverageResult.numLocationsNotCovered methods.

 

I didn't post the code because it is pretty messy, but if anyone has specific questions I'd be happy to help out and share code.

 

 

All Answers

gm_sfdc_powerdegm_sfdc_powerde
It's possible to get overall code coverage from IDE if you have all your classes in the package.xml.  Right click on classes folder and run your Force.com tests.  It shows the overall code coverage in this case.
jhartfieldjhartfield
gm_sfdc_powerde, that is how we have been running our tests, and I do see that it shows code coverage on a per class basis; but I do not see where it shows the overall percentage of code covered.  Can you describe or post a screen shot of where that is displayed?
gm_sfdc_powerdegm_sfdc_powerde
Under Failures & Warnings -> General Warnings, you should be able to see the overall code coverage.
jhartfieldjhartfield

gm_sfdc_powerde, that works when code coverage is less than 75%.  But when code coverage is above 75%, then the 'General Warnings' are not displayed.  In our case, our code coverage is above 75%, so I cannot see the overall code coverage.

 

 

jhartfieldjhartfield

It doesn't look like there is a good easy solution to this, so I made a little .NET application using the Apex web API to run the tests using the 'runTests' method.  From the test results I was able to figure out my code coverage by doing some quick math on the CodeCoverageResult.numLocations and CodeCoverageResult.numLocationsNotCovered methods.

 

I didn't post the code because it is pretty messy, but if anyone has specific questions I'd be happy to help out and share code.

 

 

This was selected as the best answer