c# - .Net application to run Apex TC through tfs build system -


i automating salesforce application using selenium , apex tc. use salesforce soap api , enterprise wsdl our dml , soql updates, queries, etc. using soap api run apex tests. run of our selenium tests through tfs build using microsoft build system. reporting reports on each test method if fail or pass. trying figure out how run each apex test method instead of running entire class.

the code below 1 selenium method runs entire apex tc class many methods. want able 1 1 , have selenium method call each apex test method not finding away this.

the selenium test method:

[testmethod]     public void testfromeventdetailssprint181()     {         //this line of code logs dev org defined in app.config , runs specified apex test class.         //   use intellisense see available properties returned in testresults. can used assert against reporting tfs.           //commonfunctionlibrary.sfapex.runtestsresult testresults = helper.runsalesforceapextestclass("testforecastedrevwithoutecupts_test", null);         commonfunctionlibrary.sfapex.runtestsresult testresults = helper.runsalesforceapextestclass("somenamespace.someclass", null);          //some notable data available in returned results assert against:         //   numtestruns = # of testmethods executed in apex test class         //   numfailures = # of failed test methods         //   failures = array of failure structures, each contains methodname , message (see below)         //   successes = array of success structures          string failuremessage = "";         if (testresults.numfailures > 0)         {             foreach (var failure in testresults.failures)             {                 failuremessage += "test failure encountered in method: " + failure.methodname + ", error: " + failure.message + ".\n";             }         }          //for demo purposes assert assumes @ least 1 testmethod fail, designed in example testclasstemplate run above.         assert.areequal(0, testresults.numfailures, failuremessage);     } 

the soap api called method run apex test class:

public static runtestsresult runsalesforceapextestclass(string testclassname, string testclassnamespace)     {         bool issandbox = !appsettings["environmenttype"].equals("developer");          servicepointmanager.securityprotocol = securityprotocoltype.tls12;          //log sfdc. retrieve session id , instance url.         soapclient soapclient = new soapclient((!issandbox ? "sfdeveloper" : "sfsandbox"));          sfpartner.loginresult loginresult = soapclient.login(null, null, appsettings["username"], appsettings["password"]);          sfapex.sessionheader apexsessionheader = new sfapex.sessionheader();         apexsessionheader.sessionid = loginresult.sessionid;          runtestsrequest runtestsrequest = new runtestsrequest();         runtestsrequest.classes = new[] { testclassname };         runtestsrequest.@namespace = (string.isnullorempty(testclassnamespace) ? appsettings["orgnamespace"] : testclassnamespace);          apexservice apexservice = new apexservice();         apexservice.url = loginresult.serverurl.replace("/u/", "/s/");   //the instance url has path change call soap service         apexservice.sessionheadervalue = apexsessionheader;          runtestsresult ret = apexservice.runtests(runtestsrequest);          return ret;      } 


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -