You need to sign in to do that
Don't have an account?
jonathanbernddf20131.387825590468351E12
test class for method called by js button
Hi folks
I have a method called by a simple js button.
Questions:
1) How do I write a test class to simulate clicking the button?
2) In surfing the web there appears to be a question as to whether test coverage is necessary? If it isn't doesn't that count against code coverage?
Simple button script is below from which you can see the name of the method (All works fine. Just need to sort out test coverage question).
I have a method called by a simple js button.
Questions:
1) How do I write a test class to simulate clicking the button?
2) In surfing the web there appears to be a question as to whether test coverage is necessary? If it isn't doesn't that count against code coverage?
Simple button script is below from which you can see the name of the method (All works fine. Just need to sort out test coverage question).
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")} var result = sforce.apex.execute("PubVersionNumber","buttonVersionNumber",{}); alert("App is Published." ); window.location.reload();
Your test method / class might look like the following:
2) Test code coverage is absolutely necessary. Not only is it an excellent idea to unit test your application, but somewhat unique to Salesforce, you have to maintain 75% code coverage when you deploy your code to production. Ideally that number should be close to 100%, but you cannot even deploy without at least 75. Furthermore, you need code coverage across each trigger to deploy as well.
Test.startTest ();
execute buttonVersionNumber(); (using my factory below)
Test.stopTest();
System.assertEquals.... does child record exist with proper values etc.
The other question I have is that I'd like to insert records from a testfactory, so I started my test like this