Comments (5)
Parametrization is usually achieved by TestCaseSource/TestSuiteSource :)
What code are you trying to execute? Can you provide some samples?
from allure-nunit.
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.
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.
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.
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)
- Attribute AllureDisplayIgnored doesn't work with ignoring testcases HOT 6
- Is it possible to add the method's parameters to report with the help of AllureStep? HOT 7
- Test name is created as a step and steps inside the tests are substeps HOT 5
- How to add a screenshot to each test step HOT 5
- If test contains await, then [AllureStep] failed with System.ArgumentNullException : Value cannot be null. (Parameter 'key') HOT 7
- Add support to Include test class name in the report HOT 1
- MaxLimit attribute doesn't logged in allure HOT 4
- "System.MissingMethodException" error appears after update NUnit from 3.13.0 to 3.13.1 version HOT 2
- Changing the version of an assembly reference is not allowed during debugging HOT 3
- Value cannot be null. (Parameter 'key') async Task HOT 1
- Could not install package 'NUnit.Allure 1.0.14' HOT 3
- Cannot find "AllureNUnit" attribute after update of from
- Cannot find "AllureNUnit" attribute after update of "NUnite.Allure" nuget package from 1.0.14 to 1.2.0 HOT 4
- NullReferenceException in AllureStepAspect.WrapStep when some of the arguments are null HOT 3
- Get test result id HOT 1
- How to enable adding Screen Diff HOT 7
- AspectInjector.targets error in Rider HOT 5
- Steps do not show in Setup HOT 1
- Edit and continue does not work due to usage of AspectInjector 2.6 HOT 2
- Archive repo HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from allure-nunit.