【问题标题】:Extensionbility of PEXPEX 的可扩展性
【发布时间】:2012-11-28 12:53:57
【问题描述】:

我已经通过 Pex,Extensions Writer Handbook,但这份文档只有 5 页,并不详尽。我需要更多关于可扩展性的信息。

我去了http://pex.codeplex.com/,它为不同的测试框架加上 DySy 和 ASE 扩展扩展了 pex。但是,它再次编写了 pex 版本 0.18,当前版本为 0.94.x。许多类被重构和改变。因此,它无法编译。

我被困在哪里,我需要根据我的逻辑扩展测试方法名称的创建,我应该从哪里开始?网络上有没有针对 pex 0.94.x 的开源项目可供我学习和参考?

【问题讨论】:

  • 我对几乎相同的场景感兴趣..

标签: pex


【解决方案1】:

你是对的,手册没有帮助 为了更改测试方法名称创建,我在此博客 http://tech.rofas.net/?tag=/code 上找到了此代码

class KeepOriginalTestNamesAttribute : PexTestNamerAttributeBase
{
    protected override IPexTestNamer CreateTestNamer(IPexExplorationComponent host)
    {
        return new TestNamer(host);
    }

    class TestNamer : PexExplorationComponentElementBase, IPexTestNamer
    {
        private readonly SafeSet<string> _names;

        public TestNamer(IPexExplorationComponent host) : base(host)
        {
            _names = new SafeSet<string>();
        }

        public bool TryCreateTestName(IPexGeneratedTest test, out string testName)
        {
            var template = ReflectionHelper.EscapeForMetadataName(test.ExplorationName.Method.ShortName);
            testName = MetadataHelper.GetUniqueNumberedName(_names, template);
            _names.Add(testName);
            Debug.WriteLine("*** " + testName + " ***");
            Debug.WriteLine(test.BodyCode);

            return true;
        }
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-16
    • 2011-07-07
    • 2016-11-20
    相关资源
    最近更新 更多