Nunit.Framework.Internal.Test
's Fixture
property is null from inside ITestBuilder
#4372
-
As a follow up to a previous issue I have been trying to implement a custom attribute using the
I decorated a test case as follows:
I would like to access Am I doing something wrong here? Why is |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
Would ICommandWrapper work for you? There is a derived IWrapSetUpTeardown marker interface you can implement to inject code to run in the SetUp/Teardown phase. https://docs.nunit.org/articles/nunit/extending-nunit/ICommandWrapper-Interface.html The docs suggest using MaxTimeAttribute as a simple, minimal example to reference: https://github.com/nunit/nunit/blob/master/src/NUnitFramework/framework/Attributes/MaxTimeAttribute.cs |
Beta Was this translation helpful? Give feedback.
-
Oh sorry I see now a bit more from the original issue. It's difficult to know without seeing the code you have which isn't working. Are you able to share a bit of what you have tried to implement in your custom attribute? |
Beta Was this translation helpful? Give feedback.
-
@amine-aboufirass The I'm still confused what you are trying to do and why you cannot call your @stevenaw Indeed the derived |
Beta Was this translation helpful? Give feedback.
-
@manfred-brands Huh, you are quite right, the callbacks passed in there are for a There's a bit of a discussion about intent of the types in the internal namespace here #1426, but as far as I can tell it wasn't clear-cut and still requires a more thorough cataloging and decision about the different types in the (sub)namespaces. I think you are right, it would help to know a bit more about what @amine-aboufirass is trying to do. |
Beta Was this translation helpful? Give feedback.
-
This is more about usage, so moving it to Q&A discussions. |
Beta Was this translation helpful? Give feedback.
@amine-aboufirass The
suite
passed in to theBuildFrom
method is theFixture
you are in and the propertyClassName
is its type. Note that you cannot call a non-static method as at the time theITestBuilder
is run, it is to create tests, not to run them and the class will not be instantiated.I'm still confused what you are trying to do and why you cannot call your
PrintHello
from the[SetUp]
method.@stevenaw Indeed the derived
ICommandWrapper
allows you to wrap tests, but the needed classTestCommand
is in theInternal
namespace so I don't know if that is really meant to be used by outside code?