FitNesse + TeamCity - add tone to the project

    Good day, lovers to clamp the designed system into a variety of tests! Many of you use tools to create system tests. Someone even uses FitNesse , which was a little talked about on Habré . Therefore, I will not repeat myself and write about what FitNesse is and what it is eaten with. I’d better tell you how to make the project “do fitness” in the assembly process, which proceeds using TeamCity .
    Interesting? Then welcome to cat.

    So, given:

    1. A project written in PHP that needs an external test framework. The developer wants to be sure that after making the changes, the end user will see exactly what he saw before plus a new chip. And not a new feature and sharply numbed UI of the neighboring report management module.
    2. System tests for controlling UI through Selenium Webdriver, written on the basis of PHPUnit. They have 2 disadvantages, namely:
      • The tester must know PHP, PHPUnit, Webdriver's API. And at the same time write clean code that not only he can read.

        Let's make his life easier :)
      • Therefore, existing tests are written in such a way that supporting them is a dark and thankless task. An even darker and ungrateful situation is when programmers are unable to immediately understand why the test actually flied. And you have to spend time ...

    3. Automatically build a project and run all tests using TeamCity
    4. A number of UI tests run by FitNesse. More readable than written in PHP, and anyone can open our FitNesse-wiki and run any test. And even managers understand what’s happening on the screen :). However, when building a project, these tests do not automatically run.


    We will solve the last point by crossing TeamCity Buildrunner and FitNesse. You can do this in different ways: you can independently configure the FitNesse runner + TeamCity bunch , or you can go the simple way and use a specially trained plug-in . Out of the box, the plugin can launch FitNesse according to the path specified in the settings, run tests and display brief statistics. In general, a miracle, but upsetting as follows:
    • There were problems when running on a BuildAgent that runs on Linux
    • FitNesse is launched every time the assembly starts. And cut down at its completion. But sometimes I want to go to the page of a specific test and look into his eyes :)

    Therefore, our team decided to take the plugin, finish it to our fantastic requirements and share with the community. The rewrite plugin is available on GitHub .
    I will briefly describe the installation and configuration process. In general, it is similar to the one described in the README of the original plugin, but now FitNesse must be launched by someone on BuilAgent in advance. And since he will rustle there all the time, you can go at any time and run any test you like with your hands.
    • Using ant, we collect the project in the archive, intended for feeding to the TeamCity server.
    • Pull TeamCity server to our archive in the plugins folder. And we reboot the server.
    • TeamCity should now update its BuildAgent with a new plugin. If something went wrong on the agents, reboot them.
    • A new runner appeared on TeamCity server - Fitnesse runner. Now you can add another build step. It is configured simply, in 2 parameters:
      FitNesse host - in fact, the address where you can open our FitNesse wiki.
      Test names - listing of tests that need to be run. The test names are written in a line, the separator is a semicolon.
    • On BuildAgent, we run FitNesse and configure it so that it picks up the tests that BuilAgent collects. In our case, this was solved by setting the variable $ FITNESSE_ROOTPATH ​​when running through the -d parameter:
      java -jar fitnesse-standalone.jar -p 8080 -d ~/BuildAgent/work/branch/test/src/Fitnesse

      And since When building BuildAgent updates the folder branch/test/src/Fitnesse, FitNesse will always have tests for the collected branch.
    • Everything, you can run the assembly.


    We can observe approximately such pictures at the exit. We will see this in the test results:

    And this is in buil logs:

    For complete happiness, it remains to make the links work “like links”, which this article can help . But this is a discussion of another plan.

    What is the profit from FitNesse?

    First, once you have developed and documented the API that is available from FitNesse, the tester will no longer be asked to write PHP code. He has the only tool - Wiki markup, with which he writes test scripts and documentation at the same time. If you need a new API-pen, then it is not the tester who will write it, but the development team. Which, in fact, pay money for the code :).
    Secondly, you can conduct documentation on the system directly on the page with tests. It will be useful for new employees to dig deeper into such a knowledge base. And the writing style of FitNesse tests is much more convenient for perception by a person familiar with English. If you wish, you can even show managers - let them see that “User Vasya logs in with password vasyapassword and receives alert with message“ PANIC !! “”, and it really works :).

    To the community.

    Please do not judge the plugin too strictly - it is still “young and inexperienced” :) If someone is interested, then do not hesitate to finish it / add it as you like. And let everyone benefit.

    Also popular now: