samedi 17 septembre 2016

Simple way to automate unit testing by logging an XML file and sending e-mail

I am new to the world of unit testing. I am currently setting up some unit+integration tests in the game engine Unity. I have a simple batch script that runs Unity via the command line and then outputs an XML file with the results (http://ift.tt/2cHIRFU).

Below is an example of a succesful test that is logged by saving an XML file on my local computer.

<?xml version="1.0" encoding="utf-8"?>
<!--This file represents the results of running a test suite-->
<test-results name="Unity Tests" total="3" errors="0" failures="0" not-run="0" inconclusive="0" ignored="0" skipped="0" invalid="0" date="2016-09-17" time="17:41:27">
  <environment nunit-version="2.6.2-Unity" clr-version="2.0.50727.1433" os-version="Microsoft Windows NT 10.0.14393.0" platform="Win32NT" cwd="C:\Users\UnitTesting_test" machine-name="Wikzo" user="Wikzo" user-domain="Wikzo" unity-version="5.4.0f3" unity-platform="StandaloneWindows" />
  <culture-info current-culture="en-US" current-uiculture="en-US" />
  <test-suite name="2_IntegrationTest" type="Assembly" executed="True" result="Success" success="True" time="4.060">
    <results>
      <test-case name="MoverTest" executed="True" result="Success" success="True" time="1.032">
        <reason>
          <message>
<![CDATA[Sent TestStarted
Pass 
]]>
          </message>
        </reason>
      </test-case>
      <test-case name="PowerUpTest" executed="True" result="Success" success="True" time="0.015">
        <reason>
          <message>
<![CDATA[Sent TestStarted
Pass 
]]>
          </message>
        </reason>
      </test-case>
      <test-case name="Sphere Drag Test" executed="True" result="Success" success="True" time="3.013">
        <reason>
          <message>
<![CDATA[Sent TestStarted
Pass (Plane)
]]>
          </message>
        </reason>
      </test-case>
    </results>
  </test-suite>
</test-results>

As I have never worked with XML nor automatic builds/testing before, I would like to get some pointers on how to approach this in a smart, yet simple, manner.

The plan right now is to run these tests via the command line in Windows every night on a local machine (maybe I will dive into servers and Jenkins in the future, but for now I am taking baby steps). Instead of manually having to read through the XML log, I would like to somehow get notified if the tests fail (result="Failure"). It would be nice if this could be done by e.g. sending me an e-mail or something similar that doesn't require too much setup.

How should I go about this? Is there an "IFTTT"-style of easy way to do this?

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire