Flosum can be tightly integrated with Selenium test cases for regression testing.

Selenium test cases can be recorded and hosted on any provider, including AWS, Azure, or any on-premise servers that customers may already have. There are no limits as long as the provider can accept an incoming web service from Flosum.

Use Cases

Most customers integrate with Flosum on one of the following two conditions:

When a new user story or release is deployed to a DevTest, QA, or UAT sandbox.
When a developer has finished the user story and committed new code to the repository. (To maintain the sanctity of the code, the code is deployed to a build organization and tested on various sandboxes. Whenever new code is committed to the repository, the regression test cases are automatically run to ensure that there are no failures in the build process.)

The following example demonstrates how cases are automatically run after a successful deployment to the target org.

In the screenshot below, the “Regression Test Classes” captures the test classes that should be executed at the end of deployment.

Once the deployment is complete, the results of the Selenium test classes are captured in the Test Results list, as shown below.

 

You can view a detailed log of the test result, as shown below, by clicking the name of the test result (TR-9 in this example).

Sample Code


public class SeleniumHttpCaller implements Queueable, Database.AllowsCallouts{

static final String SERVER_URL = 'http://ec2-3-16-54-178.us-east-2.compute.amazonaws.com:8080';

public String MetadataLogId {get; private set;}
public SeleniumHttpCaller(String metadataLogId){
this.MetadataLogId = metadataLogId;
}
public SeleniumHttpCaller(){}

public void execute(QueueableContext context){

SeleniumHttpCaller.FutureMethod(this.MetadataLogId);
}

@future(callout=true)
public static void FutureMethod (String metadataLogId){

SeleniumHttpCaller.callTestExecution();
SeleniumHttpCaller.checkTestResult(metadataLogId);
}

public static void callTestExecution(){
HTTP h = new HTTP();
HTTPRequest r = new HTTPRequest();
r.setEndpoint(SeleniumHttpCaller.SERVER_URL + '/job/devsforce/buildWithParameters');
Blob headerValue = Blob.valueOf('devsforce:11e6c770f095baff013bcecda82654fdfd');
String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
r.setHeader('Authorization', authorizationHeader);
r.setMethod('POST');
r.setBody('testCase:DoSalesforce');
HTTPResponse resp = h.send(r);
}

public static void checkTestResult(String metadataLogId){
HTTP h = new HTTP();
HTTPRequest r = new HTTPRequest();
r.setEndpoint(SeleniumHttpCaller.SERVER_URL + '/job/devsforce/lastBuild/testReport/api/json');
Blob headerValue = Blob.valueOf('devsforce:11e6c770f095baff013bcecda82654fdfd');
String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
r.setHeader('Authorization', authorizationHeader);
r.setMethod('GET');
HTTPResponse resp = h.send(r);

if(resp.getStatusCode() != 404){

TestResponseBody objTestResponseBody = new TestResponseBody(System.JSON.createParser(resp.getBody()));
List lstTestResults = new List();
Test_Result__c testResult;
for(TestResponseBody.Cases iCase : objTestResponseBody.suites[0].cases){
testResult = new Test_Result__c();
testResult.Metadata_Log__c = metadataLogId;
testResult.Error_Details__c = (iCase.errorDetails != NULL) ? iCase.errorDetails.toString() : '';
testResult.Error_Stack_Trace__c = (iCase.errorStackTrace != NULL) ? iCase.errorStackTrace.toString() : '';
testResult.Skipped__c = iCase.skipped;
testResult.Skipped_Message__c = (iCase.skippedMessage != NULL) ? iCase.skippedMessage.toString() : '';
testResult.Status__c = iCase.status;
testResult.Test_Case_Name__c = iCase.name;
testResult.Complete_Log_JSON__c = resp.getBody();

lstTestResults.add(testResult);
}

insert lstTestResults;
}
}
}

Ready to simplify your Salesforce Deployment?

Share This