1

Intellitest を使用してテスト ケースを生成できませんでした。問題を修正した後、「x 回の実行でテストを生成できませんでした」という警告が常に表示されます。従う必要のある手動の手順はありますか? または、この警告は不適切なコードが原因で発生するか、intellitest フレームワークによる制限である可能性があります。

アイデアはありますか?私はここ何日も努力してきました:/

「HolidaySetupComponent」という名前のクラスがあります。このクラス メソッド「GetEmailContent(string emailtypeTag)」のテスト ケースを作成したいと考えています。

以下は私のコードです。

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;
    }
}

「holidaySetupComponent」にある「GetEmailContent(string emailtypeTag)」メソッドで「Run intellitest」をクリックすると、次の警告が表示されます。

警告のスナップショット

このステップで、この警告を修正する必要があることを理解したので、これらのオプションですべての警告を選択し、修正を適用しました。

  • オブジェクトの作成 (2)
  • インストルメント化されていない方法 (4)

以下の警告の下にある残りの警告に対して「修正」オプションが無効になっているため、これらの警告を「無効」にします

  • ランタイム警告
  • 静的フィールド ストア

これらの修正を適用した後、intellitest は「HolidaySetupComponent」のオブジェクト作成用のファクトリ クラス「HolidaySetupComponentFactory」を作成しました。

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.
    }
}

また、警告を「抑制する」ときにintellitestによってこれらの行をPexAssemblyInfo.csに追加しました。

[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))]

この後、取り除くことができない「ランタイム警告」が表示されます

最終警告

助けが必要!!!

ありがとう

4

0 に答える 0