This is a Testing Adapter based on NUnit Testing Framework, which gathers basic build information and useful artifacts:
- test status;
- test execution time
- titled values;
- user defined files;
- screenshots;
- stack traces;
For further processing by Jenkins Test Management plugin.
- Download & Build solution or Download Ready to Use TTMNAdapter.NUnit assembly
- Make sure your Test Project is based on NUnit Testing Framework
- Add TMNAdapter.NUnit and TMNAdapter.Core references to your Test Project
- Mark your test with
JiraTestMethod
attribute to link it with Jira issue - Use
JiraInfoProvider
to attach additional data for Jira issues - Add
[assembly: GenerateTestReportForJIRA]
line to any test class file in your Test Project[assembly: GenerateTestReportForJIRA] namespace TestProject { [TestFixture] public class TestClass { // use Screenshoter to attach screenshots to the Jira issue // or you can add screenshot file with JiraInfoProvider [SetUp] public void Initialize() { Screenshoter.Instance.Initialize(Browser.Instance.GetDriver()); } [Test] [JiraTestMethod("ISSUE-KEY")] public void AwesomeTestMethod() { // use this anywhere in your tests... // attach parameter to the Jira issue JiraInfoProvider.SaveParameter("string", "awesome-string"); JiraInfoProvider.SaveParameter("bool", true); JiraInfoProvider.SaveParameter("int", 42); // attach file or screenshot to the Jira issue var fileInfo = new FileInfo("file-path"); JiraInfoProvider.SaveAttachment(fileInfo); // assert's message also will be recorded Assert.Fail("You Shall Not Pass! ¯\_(ツ)_/¯"); } //if you were using Screenshoter [TearDown] public void Cleanup() { Screenshoter.Instance.CloseScreenshoter(); } } }
- Build & Run your tests with Jenkins or manual
- Check target folder with jira-tm-report.xml file and attachments folder for TM Jenkins Plugin
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <tests> [...] <test> <key>EPMFARMATS-2447</key> <status>Failed</status> <summary>Testing failed test behavior</summary> <time>00m:00s:023ms</time> <attachments> <attachment>\target\attachments\jenkins-oops.jpg</attachment <attachment>\target\attachments\1527068327885\jenkins-oops.jpg</attachment> <attachment>\target\attachments\stacktrace_2018-05-23T12-38-47.897.txt</attachment> </attachments> <parameters> <parameter> <title>Random number</title> <value>617832599</value> </parameter> <parameter> <title>Random boolean</title> <value>0</value> </parameter> <parameter> <title>Some static string</title> <value>Hello, world!</value> </parameter> </parameters> </test> [...] </tests>
- Make sure TM Jenkins Plugin is installed and configured in Jenkins
- Check issue in Jira
- Download & Build solution or Download Ready to Use TMNAdapter.MSTest assembly
- Make sure your Test Project is based on MSTest Testing Framework
- Add TMNAdapter.MSTest and TMNAdapter.Core references to your Test Project
- Use
JiraTestMethod
instead of standartTestMethod
attribute to link tests with Jira issues - Use
JiraInfoProvider
to attach additional data for Jira issues - You need to invoke
TestReporter.GenerateTestResultXml()
method inAssemblyCleanup
to gather all test results: - Your Test Project should look something like this:
namespace TestProject { [TestClass] public class TestClass { // use Screenshoter to attach screenshots to the Jira issue // or you can add screenshot file with JiraInfoProvider [TestInitialize] public void Initialize() { Screenshoter.Initialize(Browser.Instance.GetDriver()); } [JiraTestMethod("ISSUE-KEY")] public void AwesomeTestMethod() { // use this anywhere in your tests... // attach parameter to the Jira issue JiraInfoProvider.SaveParameter("string", "awesome-string"); JiraInfoProvider.SaveParameter("bool", true); JiraInfoProvider.SaveParameter("int", 42); // attach file to the Jira issue var fileInfo = new FileInfo("file-path"); JiraInfoProvider.SaveAttachment(fileInfo); // attach a screenshot to the Jira issue Screenshoter.Instance.TakeScreenshot(); // assert's message also will be recorded Assert.Fail("You Shall Not Pass! ¯\_(ツ)_/¯"); } //if you were using Screenshoter [TestCleanup] public void Cleanup() { Screenshoter.Instance.CloseScreenshoter(); } //gathering all test results [AssemblyCleanup] public static void AssemblyOneTimeCleanup() { TestReporter.GenerateTestResultXml(); } } }
- Build & Run your tests with Jenkins or manual
- Check target folder with jira-tm-report.xml file and attachments folder for TM Jenkins Plugin
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <tests> [...] <test> <key>EPMFARMATS-2447</key> <status>Failed</status> <summary>Testing failed test behavior</summary> <time>00m:00s:023ms</time> <attachments> <attachment>\target\attachments\jenkins-oops.jpg</attachment <attachment>\target\attachments\1527068327885\jenkins-oops.jpg</attachment> <attachment>\target\attachments\stacktrace_2018-05-23T12-38-47.897.txt</attachment> </attachments> <parameters> <parameter> <title>Random number</title> <value>617832599</value> </parameter> <parameter> <title>Random boolean</title> <value>0</value> </parameter> <parameter> <title>Some static string</title> <value>Hello, world!</value> </parameter> </parameters> </test> [...] </tests>
- Make sure TM Jenkins Plugin is installed and configured in Jenkins
- Check issue in Jira
- Download & Build solution or Download Ready to Use TTMNAdapter.SpecFlow assembly
- Make sure your Test Project is based on SpecFlow Testing Framework
- Add TMNAdapter.SpecFlow and TMNAdapter.Core references to your Test Project
- Add step definitions in App.config
<specFlow>
<!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config -->
<stepAssemblies>
<stepAssembly assembly="TMNAdapter.SpecFlow" />
</stepAssemblies>
</specFlow>
- Mark your feature Tag to link it with Jira issue
- Use
JiraInfoProvider
to attach additional data for Jira issues - Your Feature file should look something like this:
Feature: CheckAuthorAndTitleInYouTubeVideoTest
@ISSUE-KEY
Scenario Outline: Check author name in youtube video
Given I navigate to https://www.youtube.com/watch?v=UKKYpdWPSL8
Then the author name "EPAM Systems Global" should be correct
- Your Steps should look something like this:
[Binding]
public class CheckAuthorAndTitleInYoutubeVideo
{
private readonly ScenarioContext scenarioContext;
private YouTubePage page;
// each your class with steps should contains ScenarioContext
public CheckAuthorAndTitleInYoutubeVideo(ScenarioContext scenarioContext)
{
if (scenarioContext == null) throw new ArgumentNullException("scenarioContext");
this.scenarioContext = scenarioContext;
page = new YouTubePage(BrowserContainer.GetBrowser(scenarioContext.ScenarioInfo.Title));
}
[Given("I navigate to (.*)")]
public void INavigateToMainPage(string mainPage)
{
JiraInfoProvider.SaveParameter("title", page.GetVideoTitle(), scenarioContext);
}
[Then("the (.*) should be correct")]
public void TheAuthorNameShouldBeCorrect(string authorName)
{
JiraInfoProvider.SaveParameter("authorName", page.GetAuthorName(), scenarioContext);
string name = page.GetAuthorName();
Assert.AreEqual(name, authorName);
}
- Build & Run your tests with Jenkins or manual
- Check target folder with jira-tm-report.xml file and attachments folder for TM Jenkins Plugin
<tests>
<test>
<key>ISSUE-KEY</key>
<status>Passed</status>
<time>00m:04s:640ms</time>
<attachments>
<attachment>\target\attachments\screenshot_2018-12-11T19-07-17.512.jpeg</attachment>
</attachments>
<parameters>
<parameter>
<title>title</title>
<value>At the End of the Day</value>
</parameter>
<parameter>
<title>authorName</title>
<value>EPAM Systems Global</value>
</parameter>
</parameters>
</test>
</tests>
- Make sure TM Jenkins Plugin is installed and configured in Jenkins
- Check issue in Jira