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
a!a! 

how to write test code the return values

public String getMainBody() {
if (this.theXMLDom != null && this.theXMLDom.getElementsByTagName('main') != null) {
return this.theXMLDom.getElementsByTagName('main')[0].nodeValue;
} else {
return '';
}
}

public String getSideBar() {
if (this.theXMLDom != null && this.theXMLDom.getElementsByTagName('sidebar') != null) {
return this.theXMLDom.getElementsByTagName('sidebar')[0].nodeValue;
} else {
return '';
}
}

public String getFooter() {
if (this.theXMLDom != null && this.theXMLDom.getElementsByTagName('footer') != null) {
return this.theXMLDom.getElementsByTagName('footer')[0].nodeValue;
} else {
return '';
}
}

public String getTracker() {
if (this.theXMLDom != null && this.theXMLDom.getElementsByTagName('tracker') != null) {
return this.theXMLDom.getElementsByTagName('tracker')[0].nodeValue;
} else {
return '';
}

 

 

for this code am notable to testcoverage for the RETURN values,

please help me.

Thanking you in Advance

 


HariDineshHariDinesh

Hi,

 

Not able to cover return method line means you test method is not reaching it.

Means you’re IF condition is not satisfied with your test data.

Make sure to give proper test data such that it satisfies the conditions in IF.

Then it will cover the Return Statement.