开发者

value generation in pex parmeterized unit test

I'm building unit testing using Pex. my problem is not all code branches are being tested, Pex keep generating parameter values that fails the same condition which make all the code after that condition not to run.

my method goes something like this:

    public void SetUp(DbSyncScopeDescription SyncScopeDesc, BasicInfo info, string dbContext = "MyDBContext")
    {
        // <pex>
       Contracts validation
        // </pex>

        string localDbConnStr = string.Empty;

        //this condition never get a parameter that results in true
        if (IsContextExist(dbContext))
        {
            localDbConnStr = ConfigurationManager.ConnectionStrings[dbContext + "Context"].ConnectionString;
        }
        else
        {
            throw new MissingFieldException("dbcontext does not exist");
        }

        // This part is never being reached
        ProvisionLocalScope(SyncScopeDesc, info.FarmId, localDbConnStr);

        info.Tables = GetSyncTablesAsSyncTableInfo(SyncScopeDesc);
        AdminOrm.Create(info.ToORM(), String.Format("name={0}AdminEntities", dbContext));
    }

I wonder if its possible to tell Pex to pass that test so all the code will be reached. if this is not possible is it possible to make Pex take the default values 开发者_运维技巧of the function parameters for one of the tests (i think this will be a good feature if its not present).

Thank you

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜