Skip to content
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

Add support for TUnit Class Constructors #1362

Merged
merged 3 commits into from
Nov 28, 2024
Merged

Conversation

SimonCropp
Copy link
Member

@SimonCropp SimonCropp added this to the 28.4.0 milestone Nov 28, 2024
@SimonCropp SimonCropp merged commit ad73307 into main Nov 28, 2024
5 checks passed
@SimonCropp SimonCropp deleted the TUnit-ClassConstructor branch November 28, 2024 07:20
@Simonl9l
Copy link

Simonl9l commented Dec 6, 2024

@SimonCropp - tested in version 28.4.0 - works as expected - Thanks!

@Simonl9l
Copy link

Simonl9l commented Dec 9, 2024

@SimonCropp - on further testing, I've run into a potential default file .received naming issue....

It seems that the file name is named per the TestHandler class constructor (DI's in my case) arguments, with the values of the parameterized tests (MyTest) being used, but not the names of those args.

If my test class is as follows:

[ClassConstructor<DependencyInjectionClassConstructor>]
public class TestHandler(IAaa aaa, IBbb bbb, ICcc ccc)
{

    [Test]
    [Arguments(true, true, false)]
    [Arguments(true, false, true)]
    public async Task MyTest(bool arg1, bool arg2, bool arg3)
    {
        Verify("true");
    }
}

I'll get two files named:
TestHandler_MyTest_aaa=true_bbb=true_ccc=false.received.txt
TestHandler_MyTest_aaa=true_bbb=false_ccc=true.received.txt

When I'd expect the file to be:
TestHandler_MyTest_arg1=true_arg2=true_arg3=false.received.txt
TestHandler_MyTest_arg1=true_arg2=false_arg3=true.received.txt

Does this make sense - and are my expectations correct - the file shod be named from the test arguments, not the handler class constructor arguments?

Am I missing anything?

@SimonCropp
Copy link
Member Author

i would have though the file name should be the combination of the args from the constructor and the args from the test method?

@Simonl9l
Copy link

Simonl9l commented Dec 9, 2024

Possibly in some scenarios. From a DI perspective the constructor args are just DI service pointers, so won't provide any useful values in the context of the test. Perhaps if the types of the constructor args are value types, but not interfaces it might make sense?

Given the example above, it seems though that the values of the test method arguments are being appended to the names of the constructor args in the equivalent positions, but not the names of the methods args, so something seems amiss.

Is any of this behavior configurable?

Thanks for engaging in this.

@Simonl9l
Copy link

@SimonCropp just following up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants