thomhurst / TUnit

A modern, fast and flexible .NET testing framework
MIT License
2.42k stars 38 forks source link

Depends on dose not pick up methods in base class #1248

Closed jacob7395 closed 6 days ago

jacob7395 commented 1 week ago

Hey, might be a general limitation but worth mentioning this issue or maybe There is a way around it.

My classes are setup like;

[ClassConstructor<DependencyInjectionClassConstructor>]
[InheritsTests]
public class SessionAccountantScenarioTests(IMediator mediator,
                                            [SubstituteInstance]
                                            IInMemoryEventHubWrapper eventHub,
                                            [SubstituteInstance]
                                            ITimeProvider timeProvider,
                                            AccountantInterfaceFactory factory,
                                            IAccountantContextTestInterface accountantContextTest,
                                            IAccountantStateInterface stateInterface) :
    AccountantScenarioTests(mediator, eventHub, timeProvider, factory, accountantContextTest, stateInterface)
public abstract class AccountantScenarioTests(IMediator mediator,
                                              IInMemoryEventHubWrapper eventHub,
                                              ITimeProvider timeProvider,
                                              AccountantInterfaceFactory factory,
                                              IAccountantContextTestInterface contextTestInterface,
                                              IAccountantStateInterface stateInterface) : AccountTestBase(timeProvider)

With a test in AccountantScenarioTests

    [Test]
    [DependsOn(nameof(Accountant_WillHaveCorrectBalance_WhenAccountantConstructed))]
    public async Task CompleteTransaction_WillOverChargeIfRequired([Matrix(2)] double initalBalance,
                                                                   [Matrix(0, 1)] double reservation,
                                                                   [Matrix(1, 20)] double charge,
                                                                   [Matrix(MarkupPercent.Zero, MarkupPercent.Forty)]
                                                                   MarkupPercent markupPercent)

My SessionAccountantScenarioTests then want's to depend on this method

    [Test]
    [DependsOn(nameof(AccountantScenarioTests.CompleteTransaction_WillOverChargeIfRequired))]
    public async Task CompleteTransaction_WillChargeUsers_EvenIfTheyLeaveTheCampaign([Matrix(2)] double initialBalance,
                                                                                     [Matrix(0, 1)] double reservation,
                                                                                     [Matrix(1, 20)] double charge,
                                                                                     [Matrix(MarkupPercent.Zero, MarkupPercent.Forty)]
                                                                                     MarkupPercent markupPercent)

I get a TUnit0004: No method found, also thanks for the error really helps ❤️ (not being sarcastic just a useful error)

thomhurst commented 6 days ago

Should be resolved in 0.3.34! Thanks for the report