-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JsonMappingException: Could not read test result file allure-results #482
Comments
I found the same defect opened in last year. IDK why allure(integration) stores so much information( |
Hi, @EvgenyMarchuk ! If a test has complicated parameters (objects with lots of transitive references, large collections, ORM entities. etc), there might be issues like that. |
Hi @delatrie |
@TonEnfer |
@delatrie |
Thank you. It will help me better understand some edgy use cases when our serialization algorithm performs poorly. At the moment, you may use the type formatters API to workaround the issue: using Allure.Net.Commons;
class ToStringFormatter<T> : TypeFormatter<T>
{
public string Format(T? value) => value?.ToString() ?? "null";
} using Allure.Net.Commons;
using NUnit.Framework;
using Moq;
[SetUpFixture]
class AllureSetup // Should be in the root namespace of the test assembly or without a namespace at all
{
[OneTimeSetUp]
public void SetupAllure()
{
AllureLifecycle.Instance.AddTypeFormatter(new ToStringFormatter<Mock<IMyRepository>>());
/* Formatters for other mocks and types that cause troubles */
}
} |
@delatrie <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Allure.Xunit" Version="2.12.0" />
<PackageReference Include="AutoFixture" Version="4.18.1" />
<PackageReference Include="AutoFixture.AutoMoq" Version="4.18.1" />
<PackageReference Include="AutoFixture.Xunit2" Version="4.18.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>
using AutoFixture;
using AutoFixture.AutoMoq;
using AutoFixture.Xunit2;
using Moq;
using Xunit;
namespace Allure482;
public class Class1
{
[
Theory,
AutoMockData
]
public void Test(
[Frozen] Mock<IFoo> testInterface
)
{
testInterface.Setup(x => x.Bar());
testInterface.Object.Bar();
testInterface.VerifyAll();
}
}
public interface IFoo
{
void Bar();
}
public class AutoMockDataAttribute(): AutoDataAttribute(() => new Fixture().Customize(new AutoMoqCustomization())); |
A much easier way to reproduce the problem: public static IEnumerable<object[]> GetMembers => [[() => { }]];
[Theory, MemberData(nameof(GetMembers))]
public void Test(Action checkResultAction)
{
checkResultAction();
} This code produces a JSON report slightly larger than 12.5 MB. It seems that Allure should include formatters for at least To resolve the issue, you can specify the following private class NewtonsoftContractResolver: DefaultContractResolver
{
protected override JsonContract CreateContract(Type objectType)
{
if (typeof(Delegate).IsAssignableFrom(objectType))
{
return base.CreateStringContract(objectType);
}
return base.CreateContract(objectType);
}
} This solution will serialize all delegates as a string. P.S. P.S.S. |
Hello! When is it going to be fixed? |
The problem is that given [Test]
public void Test(T a) { /* ... */ } we can't decide whether to include We can do some heuristics to exclude some types that obviously don't help us in the report and only blow up its size. As suggested by @TonEnfer, we can safely exclude any delegate types (including, but not limited to, However, heuristics only partially solves the problem. From my perspective, we need the following (in addition to heuristics):
Sorry for not giving you any specific dates. I want you to please be sure that this issue will be my top priority as soon as I have some time for allure-csharp. |
Xunit:
Custom logic to reduce size
|
Describe the Bug
Getting JsonMappingException using allure serve when parameters value is more than maximum allowed. But report is generated
Steps to Reproduce
Expected Behaviour
There is no error
Screenshots or Additional Context
What Language are you using?
C#
What Framework/Allure Integration you are using?
nunit 4
What version of Allure Integration you are using?
2.12
What version of Allure Report you are using?
2.27
Code of Conduct
The text was updated successfully, but these errors were encountered: