function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
David MatusowDavid Matusow 

soapSforceCom200608Apex.Apex.RunTestsRequest

I'm using this interface and want to specify a "class" to test.  While the command is successful, nothing shows as having been tested.  I am specifying the class, but do I also need to specify the unique test?  How do I format this specification?
pconpcon
You have to specify the class that contains the tests.  For example, I have a trigger on my Contact object and I have a test class called Contact_Test.cls I would send the following payload
 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:apex="http://soap.sforce.com/2006/08/apex">
   <soapenv:Header>
      <apex:SessionHeader>
         <apex:sessionId>${#Project#sessionid}</apex:sessionId>
      </apex:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <apex:runTests>
         <apex:RunTestsRequest>
            <apex:allTests>false</apex:allTests>
            <apex:classes>Contact_Test</apex:classes>
         </apex:RunTestsRequest>
      </apex:runTests>
   </soapenv:Body>
</soapenv:Envelope>

After this call is made, I would get something like this in return.
 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://soap.sforce.com/2006/08/apex" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Body>
      <runTestsResponse>
         <result>
            <apexLogId>07L1100000jHlq3EAC</apexLogId>
            <codeCoverage>
               <id>01q110000004dvsAAA</id>
               <locationsNotCovered>
                  <column>0</column>
                  <line>7</line>
                  <numExecutions>0</numExecutions>
                  <time>-1.0</time>
               </locationsNotCovered>
               <name>EscalationTeam</name>
               <namespace xsi:nil="true"/>
               <numLocations>1</numLocations>
               <numLocationsNotCovered>1</numLocationsNotCovered>
               <type>Trigger</type>
            </codeCoverage>
            <codeCoverage>
               <id>01qA0000000qQpKIAU</id>
               <locationsNotCovered>
                  <column>0</column>
                  <line>7</line>
                  <numExecutions>0</numExecutions>
                  <time>-1.0</time>
               </locationsNotCovered>
               <name>CaseFolder</name>
               <namespace xsi:nil="true"/>
               <numLocations>1</numLocations>
               <numLocationsNotCovered>1</numLocationsNotCovered>
               <type>Trigger</type>
            </codeCoverage>
            <numFailures>0</numFailures>
            <numTestsRun>2</numTestsRun>
            <successes>
               <id>01p11000000KG44AAG</id>
               <methodName>canCreateContactWithSpecificRecordType</methodName>
               <name>Contact_Test</name>
               <namespace xsi:nil="true"/>
               <time>3604.0</time>
            </successes>
            <successes>
               <id>01p11000000KG44AAG</id>
               <methodName>cannotUpdateContactRecordType</methodName>
               <name>Contact_Test</name>
               <namespace xsi:nil="true"/>
               <time>384.0</time>
            </successes>
            <totalTime>3999.0</totalTime>
         </result>
      </runTestsResponse>
   </soapenv:Body>

Assuming you are getting this data back, can you please expand on what you mean by "nothing shows as being tested"  Where are you looking to see what is "being tested"
David MatusowDavid Matusow
In looking at RunTestsResult, I get the following:
USER_DEBUG [45]|DEBUG|RunTestsResult:[apexLogId=null, apexLogId_type_info=(apexLogId, http://soap.sforce.com/2006/08/apex, null, 0, 1, false), apex_schema_type_info=(http://soap.sforce.com/2006/08/apex, true, false), codeCoverage=null, codeCoverageWarnings=null, codeCoverageWarnings_type_info=(codeCoverageWarnings, http://soap.sforce.com/2006/08/apex, null, 0, -1, false), codeCoverage_type_info=(codeCoverage, http://soap.sforce.com/2006/08/apex, null, 0, -1, false), failures=null, failures_type_info=(failures, http://soap.sforce.com/2006/08/apex, null, 0, -1, false), field_order_type_info=(apexLogId, codeCoverage, codeCoverageWarnings, failures, numFailures, numTestsRun, successes, totalTime), numFailures=0, numFailures_type_info=(numFailures, http://soap.sforce.com/2006/08/apex, null, 1, 1, false), numTestsRun=0, numTestsRun_type_info=(numTestsRun, http://soap.sforce.com/2006/08/apex, null, 1, 1, false), successes=null, successes_type_info=(successes, http://soap.sforce.com/2006/08/apex, null, 0, -1, false), totalTime=0.0, totalTime_type_info=(totalTime, http://soap.sforce.com/2006/08/apex, null, 1, 1, false)]

I pull this apart with a series of debug msgs as:
USER_DEBUG [46]|DEBUG|failures 0
USER_DEBUG [47]|DEBUG|runs 0
USER_DEBUG [49]|DEBUG|log null
USER_DEBUG [50]|DEBUG|codeCoverage null
USER_DEBUG [51]|DEBUG|successes null
David MatusowDavid Matusow
My input looks very similar.

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header>
<SessionHeader xmlns="http://soap.sforce.com/2006/08/apex">
<sessionId>sessionID</sessionId>
</SessionHeader>
</env:Header>
<env:Body>
<runTests xmlns="http://soap.sforce.com/2006/08/apex">
<RunTestsRequest>
<allTests>false</allTests>
<classes>ConsoleController</classes>
<namespace/>
</RunTestsRequest>
</runTests>
</env:Body>
</env:Envelope>

You can see that the result is not in xml form and that it shows all had failed.

An interest is for the test class, there are four or five tests defined.  I tried using the class and assumed it would trigger all the tests, but maybe there's something more needed to define which of the tests.  I then tried specifying a single test but (as I expected) this got no better an answer.

Thoughts???
David MatusowDavid Matusow
Does the test class require having "test" in the name??  Someone was suggesting this as a requirement.
pconpcon
No, the class does not have to have "test" in the name, but it is typically a standard.  It makes it easier to decern which classes are test classes.  Do you have methods inside your ConsoleController that are marked as @isTest and are testMethod?