-
Notifications
You must be signed in to change notification settings - Fork 722
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
How to test specific base class? #2318
Comments
Hey @Thaina! We were just talking about this. Here is what I would recommend you do: #2309 (comment) Does that suit your needs? |
Oops, wrong button. 😛 |
@jnm2 Well, not so wrong because it is. But I just think it should be natively support though |
Thanks for letting us know your opinion. I think you're only the second person to ask for it so far, but we'll reconsider if enough people end up asking. |
@Thaina You are trying to do something that NUnit is not designed to do, so any change request is a request for a change in how NUnit fundamentally works. That's not to say it's impossible, but it means (1) you need some good reasons why we might do it and (2) you should at least consider how the designers of NUnit thought this kind of situation ought to work. If I understand what you are saying, you have a test written like this... public class BaseClass
{
// Maybe common setup and teardown and other tests
[Test]
public void SomeTest() { }
}
public class DerivedClass : BaseClass
{
// This class runs it's own tests plus SomeTest from base
}
public abstract class BaseClass
{
// Maybe common setup and teardown and other tests
}
public class DerivedClass1 : BaseClass
{
// This class runs it's own tests plus SomeTest from base
}
public class DerivedClass2 : BaseClass
{
[Test]
public void SomeTest() { }
} In this design, the base class is never executed directly. It participates through inheritance in the execution of the two derived classes. This is not, obviously, the only way it could have been done, but it is how NUnit was designed to work. Base classes are intended to be abstract and not to supply any tests directly. They only supply them to the classes that derive from them. This is a description of how NUnit works, right now. If you can fit into this pattern, life will be easier, even though you can still ask for us to change things at some point. |
I have a class want to test that was inherited in the same assembly. That class has a test function that need to test just on the base class. I want the test to only run once, not run on inherited
How could I do?
The text was updated successfully, but these errors were encountered: