Replies: 10 comments 37 replies
-
Maybe I overlooked something (I made my first TUnit steps today), but I miss a feature that you can generate the data on the specified types. Currently I am using xUnit in conjunction with AutoFixture. Basically you have to implement a Create method with all defined types as parameters. The attribute subclassing is not the perfect solution, but it does what is needed. In the end I want to write a test like this:
From your documentation I can only find the MethodDataSource, but there is no way to get the information about the arguments of the test. |
Beta Was this translation helpful? Give feedback.
-
Hi,
Do I have the ability to repeat the test in growing intervals?
For instance, if the test fails because of a loss of connection, can I
repeat it after 10 sec min, and if still fails, then after 25 seconds,
then after 1 min?
…On Thu, Sep 26, 2024 at 7:11 PM Tom Longhurst ***@***.***> wrote:
Is there a feature that other frameworks provide that TUnit doesn't?
Is there a feature that they don't support but you wish they did?
I'm open to suggestions on anything that'd help make TUnit meet your
testing needs.
—
Reply to this email directly, view it on GitHub
<#646>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AENYVK4NKS4QI3QKYPCOLZ3ZYQ55RAVCNFSM6AAAAABO5PCE6WVHI2DSMVQWIX3LMV43ERDJONRXK43TNFXW4OZXGI2DAMZSGI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Vow! Do you have any notion of when will this come out of prerelease?Can’t wait to start using this.On 4. Oct 2024, at 00:49, Tom Longhurst ***@***.***> wrote:
Hey @MiroKov ! Yeah this can easily be done.
You can create your own retry attributes that simply inherit from RetryAttribute. Then you can plug your own logic into the ShouldRetry method.
It returns a task so you can wait asynchronously in there.
E.g.
public class ExponentialRetryAttribute(int times) : RetryAttribute(times)
{
public override async Task<bool> ShouldRetry(TestContext context, Exception exception, int currentRetryCount)
{
await Task.Delay(TimeSpan.FromSeconds(currentRetryCount));
return true;
}
}
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
👍On 4. Oct 2024, at 07:29, Tom Longhurst ***@***.***> wrote:
Hopefully in the next couple of months.
I'm just collecting user feedback before I mark the API as stable
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Is there some way to combine multiple In my case I want to run all my tests with different with different fixtures, so I have a base class with a Here's a quick example: [TestFixtureSource(typeof(DatabaseFixtureSource))]
public abstract class WebserverTests
{
protected WebserverTests(WebserverFixture fixture)
{
Fixture = fixture;
}
protected WebserverFixture Fixture { get; }
}
public sealed class ExampleTests(WebserverFixture fixture) : WebserverTests(fixture)
{
[Test]
public void Test() => Assert.Pass();
}
[TestFixtureSource(typeof(OtherFixtureSource))]
public sealed class CombinedTests(WebserverFixture fixture, OtherFixture other) : WebserverTests(fixture)
{
[Test]
public void Test() => Assert.Pass();
} I'm not really sure what would be the best way to port this to One thing I couldn't figure out in |
Beta Was this translation helpful? Give feedback.
-
A feature that would be really useful would be what xUnit is calling two-phase parametrised tests. (Although it has yet to be implemented) The idea is that a data source (such as from a DataSourceGeneratorAttribute) can interrupt the enumeration of generated test cases. This is very useful for property-based testing libraries that generate multiple random test cases for a single parameterised test method. The original xUnit issue is here xunit/xunit#1719 but to paraphrase, the process is:
In the shrinking phase, the property-based testing library uses various heuristics to simplify the (randomly generated) test case to a single human-readable repro. The problem with xUnit and other existing libraries is that they see both these generated test cases and the test cases generated by the shrinking algorithm as a single test, not a parameterised one with multiple inputs, making the test runner results unhelpful. I don't think TUnit supports this yet (although if I'm wrong, I'd happily be corrected), but I'd have thought it'd be much easier to implement while the framework is still young. |
Beta Was this translation helpful? Give feedback.
-
It took a while for me to check back to this thread. As for the AutoFixture part, I dont think that the current implementation would fit my developers. There is no point in type checking. It just makes writing tests painful. The whole idea of writing tests with AutoFixture is that you just write parameters in your tests and they will be created behind the scenes. When I change the type of the parameter to another, then I need another parameter. This would force to change every parameter twice with no benefit. Also if you write a migration from xUnit, where you currently just subclass the AutoDataAttribute to e.g. AutoNSubstiuteDataAttribute. You would be forced to subclass every generic attribute. Writing a lot of useless code. This is done just to override the Fixture factory, so there are other ways to solve this. A matter of how much different TUnit should feel. It makes combinations also very hard to implement. Something like InlineAutoDataAttribute would need number of generic arguments minus one constructors. |
Beta Was this translation helpful? Give feedback.
-
I'm trying out TUnit by replacing xUnit in a small project. I'm using XUnit.Combinatorial, where the use of enums as test method parameters automatically generates a test case for each value in the enum. This is what I'm able to do with XUnit.Combinatorial: public enum MyEnum { Foo, Bar, Baz }
[Theory]
[Combinatorial]
public void MyTest(MyEnum enumValue)
{
// This generates a test for Foo, Bar, and Baz
} |
Beta Was this translation helpful? Give feedback.
-
With the demise of FluentAssertions, I find myself missing the CompleteWithinAsync() and NotThrowAfterAsync assertions. Is this available and/or planned ? |
Beta Was this translation helpful? Give feedback.
-
Hey @thomhurst! Something like this maybe where you could specify a method in the
Would that be feasible and something you can imagine as a good addition? |
Beta Was this translation helpful? Give feedback.
-
Is there a feature that other frameworks provide that TUnit doesn't?
Is there a feature that they don't support but you wish they did?
I'm open to suggestions on anything that'd help make TUnit meet your testing needs.
Beta Was this translation helpful? Give feedback.
All reactions