Giter Site home page Giter Site logo

Comments (5)

unickq avatar unickq commented on May 29, 2024

Parametrization is usually achieved by TestCaseSource/TestSuiteSource :)

What code are you trying to execute? Can you provide some samples?

from allure-nunit.

dnbr2002 avatar dnbr2002 commented on May 29, 2024

Sure. I'm a bit a mixed bag. I use xUnit Runners and Asserts because that is what my pipeline is configured to use but Im using allure nunit features to pump up my reports in Jenkins. Here is an example parameterized integration test that is not generating results in the json file for allure report.

using System;
using System.Text;
using Xunit;
using Microsoft.AspNetCore.Mvc.Testing;
using System.Threading.Tasks;
using System.Net.Http;
using Newtonsoft.Json.Linq;
using System.IO;
using System.Reflection;
using Allure.Commons;
using NUnit.Allure.Attributes;
using NUnit.Allure.Core;
using NUnit.Framework;
using Assert = Xunit.Assert;
using Theory = Xunit.TheoryAttribute;

namespace MFDAPI.integrate
{
    [TestFixture]
    [AllureNUnit]
    [AllureDisplayIgnored]
    public class ApiUnitPostTest 
    {
        public HttpClient client { get; }

        public ApiUnitPostTest()
        {
            client = new HttpClient();
            client.BaseAddress = new Uri(Environment.GetEnvironmentVariable("SERVICE_HOST_URL"));

        }
        [Fact]
        public void Dispose()
        {
            client.Dispose();
        }

        [Theory]
	[NUnit.Framework.Theory]   <-----thought this would trigger results like [Test] attribute paired with [Fact] attribute did in non parameterized xUnit Tests
        [Description("check target mainframe route returns correct HttpResponseMessage type")]
        [AllureTag("Integration", ".NetCore", "WebApi", "PCOMX.MFDAPI")]
        [AllureSeverity(SeverityLevel.normal)]
        [AllureTms("PCOMX-172", "https://jira.mycompany.com/projects/PCOMX/issues/")]
        [AllureOwner("X and Y")]
        [AllureSuite("Integration Tests")]
        [AllureSubSuite("Mainframe Content Tests")]
        [InlineData("mfd/xxx")]
        [InlineData("mfd/xxy")]
        public async Task MainframeRouteReturnMessageTest(string uri)
        {
            //arrange      
            Console.WriteLine($"expected {new HttpResponseMessage().GetType()} http response message from mainframe api");
            HttpRequestMessage h = new HttpRequestMessage();
            uri = $"{client.BaseAddress}{uri}";

            //act
            var response = await client.PostAsync(uri, h.Content);

            //assert            
            Assert.IsType<HttpResponseMessage>(response);
            Console.WriteLine($"actual http response message from mainframe api: {response.GetType()}");
        }
    }
}

from allure-nunit.

unickq avatar unickq commented on May 29, 2024

Theory = Xunit.TheoryAttribute;

It looks like you trying to run xunit tests with nunit plugin. That's why it doesn't work

from allure-nunit.

dnbr2002 avatar dnbr2002 commented on May 29, 2024

I am using Xunit Theory because I am Xunit runner which needs [Fact] or Xunit based [Theory] to run xUnit tests and asserts. But if you look at my test attribute above I have both Theories on my tests thinking it would hopefully show in Allure reports .

[Theory]
[NUnit.Framework.Theory]

Here is example of xUnit Fact tests that works with Nunit [Test] attribute the same way in my other test classes. I have to do tthis get all this extra info into my Allure report from my xUnit tests since xUnit doesn't come with it's own attributes in Allure.

using System;
using System.Net.Http;
using System.Threading.Tasks;
using Xunit;
using Allure.Commons;
using NUnit.Allure.Attributes;
using NUnit.Allure.Core;
using NUnit.Framework;
using Assert = Xunit.Assert;

namespace MFDAPI.integrate
{
    [TestFixture]
    [AllureNUnit]
    [AllureDisplayIgnored]
    public class ApiHealthTest : IDisposable
    {

        public HttpClient client { get; }

        public void Dispose()
        {
            client.Dispose();
        }

        public ApiHealthTest()
        {
            client = new HttpClient();
            client.BaseAddress = new Uri(Environment.GetEnvironmentVariable("SERVICE_HOST_URL"));
        }

        [Fact]
        [Test(Description = "ping test")]
        [AllureTag("Integration", ".NetCore", "WebApi", "PCOMX.MFDAPI")]
        [AllureSeverity(SeverityLevel.trivial)]
        [AllureTms("PCOMX-172", "https://www.mycompanyjira.com/browse/PCOMX-172")]
        [AllureOwner("Developers")]
        [AllureSuite("Integration Tests")]
        [AllureSubSuite("Health Tests")]
        public async Task TestHelloWorld()
        {
            using (HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Get, "/info"))
            {
                //act
                Console.WriteLine($"expected {"Coming Soon:)"}");
                var response = await client.SendAsync(requestMessage);
                response.EnsureSuccessStatusCode();
                var responseBody = await response.Content.ReadAsStringAsync();

                //asert
                Assert.Equal("Coming Soon :)", responseBody);
                Console.WriteLine($"actual is {responseBody}");
            }
        }

from allure-nunit.

unickq avatar unickq commented on May 29, 2024

So, in this case, you'll need to fork and debug both xunit and nunit.
It's not an issue of this plugin

from allure-nunit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.