在 .net 中使用 slim Fitnesse 的分步教程

发布于 2024-11-12 17:11:57 字数 159 浏览 8 评论 0原文

有人知道在 .net 中使用 slim Fitnesse 的分步教程吗?

现在,我设法在 localhost:3434 上运行 slim Fitnesse 网站

,并将 fitSharp 插件解压到 c:/fitSharp 中

,但我不知道接下来会发生什么

anybody knows some step by step tutorial for using slim fitnesse in .net ?

for now I managed to run the slim fitnesse website on my localhost:3434

and I unziped the fitSharp plugin in c:/fitSharp

but I have no idea what's next

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

慢慢从新开始 2024-11-19 17:11:57

FitNesse 是一个wiki,其中包含可以执行系统测试的表格。然后 Tables 将告诉 FitNesse 创建一些类,对它们执行一些操作,并检查结果。

例如,为了使用 .NET,您只需告诉 FitNesse 如何与 .NET 链接以及要加载哪些 .NET 程序集。没有别的了。 .NET 项目可以是一个简单的类库,根本不需要了解 FitNesse。

需要工具

  • FitNesse - 基于 Java 的 FitNesse wiki 和测试框架。
  • fitSharp - 包含用于编写 FIT 和 SliM 装置的 .NET 库。

示例步骤

  1. 下载FitNessefitSharp
    (在此示例中,fitSharp 已提取到 D:\fit\fitSharp\release.1.9.net.35\

  2. 从命令行启动 FitNesse:

    java -jar Fitnesse.jar -p 8080
    
  3. 使用以下命令创建并编译 C# 类库项目:

    命名空间 ClassLibrary1
    {
        公共课ShouldIBuyMilk
        {
            私有 int _cash;
            私有 int _pintsOfMilkRemaining;
            私有字符串_useCreditCard;
    
            公共无效SetCashInWallet(int cash)
            {
                _cash = 现金;
            }
    
            公共无效SetCreditCard(字符串useCreditCard)
            {
                _useCreditCard = useCreditCard;
            }
    
            公共无效SetPintsOfMilkRemaining(int品脱)
            {
                _pintsOfMilkRemaining = 品脱;
            }
    
            公共字符串 GoToStore()
            {
                if (_cash > 0 || _useCreditCard.Equals("是"))
                    返回“是”;
                返回“否”;
            }
        }
    }
    
  4. 浏览到 http://localhost:8080/ 然后单击标题旁边的“[添加子项]”并添加“测试”页面。

  5. 输入如下所示的 wiki 页面内容(更新路径):

    !define TEST_SYSTEM {slim}
    !define COMMAND_PATTERN {%m -r fitSharp.Slim.Service.Runner,D:\fit\fitSharp\release.1.9.net.35\fitsharp.dll %p}
    !define TEST_RUNNER {D:\fit\fitSharp\release.1.9.net.35\Runner.exe}
    
    !路径 D:\fit\MyFixture\ClassLibrary1\bin\Debug\ClassLibrary1.dll
    
    !|导入|
    |类库1|
    
    |该不该买牛奶|
    |钱包里的现金|信用卡|还剩一品脱牛奶|去商店吗?|
    | 0 |没有| 0 |没有|
    | 10 | 10没有| 0 |是的|
    | 0 |是的| 0 |是的|
    | 10 | 10是的| 0 |是的|
    | 0 |没有| 1 |没有|
    

    注意“!” !|import| 之前是为了避免“ClassLibrary1”被视为 wikiword。

  6. 保存,然后单击左侧菜单中的“测试”。
        FitNesse 将加载程序集,创建类的实例,按照命名约定映射设置一些属性,最后检查一些属性。

    另请参阅

FitNesse is a wiki with tables that can be executed to do system testing. Tables will then tell FitNesse to create some classes, do some operations on them, and check the result.

In order to work with .NET for example, you simply need to tell FitNesse how to link with .NET and which .NET assemblies to load. Nothing else. The .NET project can be a simple class library with no knowledge of FitNesse at all.

Requires tools

  • FitNesse - The Java-based FitNesse wiki and testing framework.
  • fitSharp - Contains .NET libraries to write FIT and SliM fixtures.

Sample steps

  1. Download FitNesse and fitSharp
    (in this example fitSharp has been extracted to D:\fit\fitSharp\release.1.9.net.35\)

  2. Start FitNesse from the command-line:

    java -jar fitnesse.jar -p 8080
    
  3. Create and compile a C# Class Library project with:

    namespace ClassLibrary1
    {
        public class ShouldIBuyMilk
        {
            private int _cash;
            private int _pintsOfMilkRemaining;
            private string _useCreditCard;
    
            public void SetCashInWallet(int cash)
            {
                _cash = cash;
            }
    
            public void SetCreditCard(string useCreditCard)
            {
                _useCreditCard = useCreditCard;
            }
    
            public void SetPintsOfMilkRemaining(int pints)
            {
                _pintsOfMilkRemaining = pints;
            }
    
            public string GoToStore()
            {
                if (_cash > 0 || _useCreditCard.Equals("yes"))
                    return "yes";
                return "no";
            }
        }
    }
    
  4. Browse to http://localhost:8080/ then click '[add child]' next to the title and add a 'Test' page.

  5. Type in the wiki page content like below (update the paths):

    !define TEST_SYSTEM {slim}
    !define COMMAND_PATTERN {%m -r fitSharp.Slim.Service.Runner,D:\fit\fitSharp\release.1.9.net.35\fitsharp.dll %p}
    !define TEST_RUNNER {D:\fit\fitSharp\release.1.9.net.35\Runner.exe}
    
    !path D:\fit\MyFixture\ClassLibrary1\bin\Debug\ClassLibrary1.dll
    
    !|import|
    |ClassLibrary1|
    
    |Should I buy milk|
    |cash in wallet|credit card|pints of milk remaining|go to store?|
    |      0       |    no     |      0                |    no      |
    |      10      |    no     |      0                |    yes     |
    |      0       |    yes    |      0                |    yes     |
    |      10      |    yes    |      0                |    yes     |
    |      0       |    no     |      1                |    no      |
    

    Note the '!' before !|import| is to avoid 'ClassLibrary1' to be seen as a wikiword.

  6. Save it, and click "Test" in the left menu.
        FitNesse will load the assembly, create an instance of your class, set some properties by following the naming convention mapping, and finally check some properties.

    See also

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文