惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
MyScale Blog
MyScale Blog
博客园 - Franky
The Cloudflare Blog
IT之家
IT之家
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
WordPress大学
WordPress大学
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
The Blog of Author Tim Ferriss
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
Google DeepMind News
Google DeepMind News
P
Proofpoint News Feed
Martin Fowler
Martin Fowler
aimingoo的专栏
aimingoo的专栏
J
Java Code Geeks
腾讯CDC
雷峰网
雷峰网
Microsoft Azure Blog
Microsoft Azure Blog
G
Google Developers Blog
博客园 - 【当耐特】
美团技术团队
云风的 BLOG
云风的 BLOG

博客园 - 一一九九

Introduce to MEF (Study)- one 【wpf】AnimatedTabControl 如何显示内容 [wpf]设置Application的ICO Error: does not contain a static 'Main' method suitable for an entry point [wpf] Can you outline a story-driven process with Concordion? Your First Concordion.Net Project (Part 4)-More Specifications! Your First Concordion.Net Project (Part 3)-Adding Specifications Your First Concordion.Net Project (Part 2)-Setting Up Visual Studio Your First Concordion.NET Project (Part 1)-What is Concordion.Net? [Specification by Example][ch5 Deriving scope from goals]-[读书笔记]-[4] [Specification by Example][ch5 Deriving scope from goals]-[读书笔记]-[3] [Specification by Example][ch5 Deriving scope from goals]-[读书笔记]-[2] [Specification by Example][ch5 Deriving scope from goals]-[读书笔记]-[1] [Specification by Example][ch4 Initiation the changes]-[读书笔记] [Specification by Example][ch3 Living documentation]-[读书笔记] [Specification by Example][ch2 key process patterns]-[读书笔记] [Specification by Example][ch1 key benefits]-[读书笔记] Binding Resource
Your First Concordion.Net Project (Part 5)-Running Specs ...
一一九九 · 2012-01-16 · via 博客园 - 一一九九

2012-01-16 17:23  一一九九  阅读(286)  评论()    收藏  举报

http://living-in-concordion.blogspot.com/2009/05/your-first-concordionnet-project-part-5.html

需要一些自动运行Spec的Runner,这里采用的为Gallio写的一个插件。

Gallio是一个开源的测试框架,能够运行各种.net的测试框架,具有较高的扩展能力和丰富的报表系统

那么为了让Gallio能够运行我们的Spec,我们需要编写一个插件。在Concordion的发布文件中,你会看到一个目录叫做Gallio.ConcorionAdaper.这个微微Gallio编写的插件。

我喜欢在运行Spec的时候以Gallio.Echo的方式开始。这是一个可执行文件,而且很容易调试问题。Gallio还有GUI的runner,比如Lcarus.

我们在Specification项目的根目录下创建Specification文件,如下图所示:
Calculator.Sample.11_thumb[1]

这个文件叫做run-spec-with-echo.cmd。我们需要告诉Gallio到哪里找Gallio.ConcordionAdapter插件,以及到哪里找我们的Specification Assembly. 文件夹的内容如下:

Calculator.Sample.12_thumb[1]

在命令行中添加如下命令来告诉Gallio到哪里找目录:/pd:c:\Concordion\Gallio.ConcordionAdapter , 这会使Gallio在这个目录中搜索.plugin文件。然后我们需要告诉Concordion 哪里找到我们的Specification  assembly。bin\Debug\Calculator.Spec.dll。 既然批处理文件是在我们的项目目录中,但是我们的Spec程序集是在项目的输出目录中,我们需要添加到Spec的相对路径。除非明确的执行,Gallio.Echo的路径也是在当前目录下:我们的命令行应该如下所示:

set GALLIO_PATH=C:\Dev\concordion-net\tools\Gallio-trunk\bin
 
%GALLIO_PATH%\Gallio.Echo.exe /pd:c:\Concordion\Gallio.ConcordionAdapter bin\debug\Calculator.Spec.dll
 
pause

运行这个文件,你可能会遇到如下的输出结果:

Calculator.Sample.13_thumb[3]

Fixing the Fixture


修改我们的Calculator Class如下所示:

   1:  public class Calculator
   2:  {
   3:      public long Add(long first, long second)
   4:      {
   5:          return first + second;
   6:      }
   7:   
   8:      public long Subtract(long first, long second)
   9:      {
  10:          return first - second;
  11:      }
  12:   
  13:      public long Multiply(long first, long second)
  14:      {
  15:          return first * second;
  16:      }
  17:   
  18:      public long Divide(long first, long second)
  19:      {
  20:          return first / second;
  21:      }
  22:  }

修改我们的测试代码如下所示:

  [ConcordionTest]
  public class ArithmeticTest
  {
      public long firstOperand;
      public long secondOperand;

      public long Addition(long first, long second)
      {
          return new Calculator().Add(first, second);
      }

      public long Subtraction(long first, long second)
      {
          return new Calculator().Subtract(first, second);
      }

      public long Multiplication(long first, long second)
      {
          return new Calculator().Multiply(first, second);
      }

      public long Division(long first, long second)
      {
          return new Calculator().Divide(first, second);
      }
  }

再次运行后,运行结果如下所示:

image_thumb[2]

最终的HTML的输出结果如下所示:

image_thumb[4]

If you want to see the source code for this series of posts you can download it here.

This sample was pretty basic but it should be enough to get you up and running!

Thanks for trying out this tool, I hope you enjoy it. Stay tuned, there will be more to come on advanced features of Concordion!