I Could not generate test cases by using intellitest. After fixing issues i always come to point where i got warning that "Could not generate any test in x runs".Is there any manual step i need to follow? or this warning comes due to bad code or may be any limitations by intellitest framework.
Any ideas please ? I've been trying for the last many days :/
I am having a class named "HolidaySetupComponent". I want to create test cases for this class method "GetEmailContent(string emailtypeTag)".
Below is my code.
public class HolidaySetupComponent
{
private string table1;
private string table2;
private string table3;
public String _CompanyId;
int _CompId;
string connectionString= ConfigurationManager.ConnectionStrings["HCMSConnectionString"].ConnectionString;
DataServices dataservice = new DataServices();
public HolidaySetupComponent()
{
dataservice.BeginProcess(connectionString);
table1 = "tblHoliday";
table2 = "tblSetupsDetail";
table3 = "tblEmailHistory";
_CompanyId = Utilities.GetCompanyId();
}
public DataSet GetEmailContent(string emailtypeTag)
{
DataSet ds = new DataSet();
int emailtypetagId = 0;
if (emailtypeTag == "NationalTab")
{
emailtypetagId = 4;
}
else { emailtypetagId = 5; }
string whereclause = "EmailType = " + emailtypetagId + "AND CompanyId =" + Utilities.GetCompanyId();
string result = dataservice.GetDataWithClause("*", "tblEmailContentCreation", whereclause, ref ds);
return ds;
}
}
public static class Utilities
{
static DataServices dataService = new DataServices();
static DataServices dataServiceAuditTrail = new DataServices();
public Utilities()
{
dataService.BeginProcess(ConfigurationManager.ConnectionStrings["HCMSConnectionString"].ConnectionString);
dataServiceAuditTrail.BeginProcess(ConfigurationManager.ConnectionStrings["vCurioAuditTrailConnectionString"].ConnectionString);
}
public static String GetCompanyId()
{
var _clientIP = HttpContext.Current.Request.Headers.GetValues("login");
string prefix = Utilities.GetPrefix(_clientIP[0]);
string _loginDetail = Utilities.GetKeyInRedis(prefix + "OtherData");
DataTable dtloginDetail = (DataTable)JsonConvert.DeserializeObject(_loginDetail, (typeof(DataTable)));
String _CompanyId = String.Empty;
if (dtloginDetail != null && dtloginDetail.Rows.Count != 0)
{
DataRow drloginDetail = dtloginDetail.Rows[0];
_CompanyId = drloginDetail["CompanyId"].ToString();
}
return _CompanyId;
}
}
When i click on "Run intellitest" on "GetEmailContent(string emailtypeTag)" method exist in "holidaySetupComponent" i got following warnings.
At this step as i understand that i need to fix this warning so I selected all warnings under these options and apply fix.
- Object Creation (2)
- Uninstrumented Method (4)
"Fix" option was disabled for remaing warnings under below warning so i "Supperss" these warnings
- Runtime Warning
- Static Field Store
After applying these fixes intellitest created a factory class "HolidaySetupComponentFactory" for object creation of "HolidaySetupComponent"
public static partial class HolidaySetupComponentFactory
{
///<summary>A factory for HolidaySetupComponent instances</summary>
[PexFactoryMethod(typeof(global::HolidaySetupComponent))]
public static global::HolidaySetupComponent Create(string _CompanyId_s)
{
global::HolidaySetupComponent holidaySetupComponent
= new global::HolidaySetupComponent();
holidaySetupComponent._CompanyId = _CompanyId_s;
return holidaySetupComponent;
// TODO: Edit factory method of HolidaySetupComponent
// This method should be able to configure the object in all possible ways.
// Add as many parameters as needed,
// and assign their values to each field by using the API.
}
}
and also added these lines in PexAssemblyInfo.cs by intellitest when i "suppress" warnings.
[assembly: PexInstrumentAssembly("System.Configuration")]
[assembly: PexInstrumentType(typeof(Attribute))]
[assembly: PexInstrumentType(typeof(TextReader))]
[assembly: PexSuppressStaticFieldStore("System.ComponentModel.ReflectTypeDescriptionProvider", "_intrinsicTypeConverters")]
[assembly: PexSuppressStaticFieldStore(typeof(AttributeCollection), "_defaultAttributes")]
[assembly: PexSuppressStaticFieldStore("System.ComponentModel.ReflectTypeDescriptionProvider", "_attributeCache")]
[assembly: PexInstrumentAssembly("System.Xml")]
[assembly: PexSuppressExplorableEvent(typeof(global::HolidaySetupComponent))]
After this i get "Runtime Warning" that i cannot rid off
Need Help!!!
Thanks