Add support for Theories in nested test classes#3857
Conversation
mikkelbu
left a comment
There was a problem hiding this comment.
@nunit/framework-team I don't see a problem with adding this flag, as the addition is compatible with existing code. Do any of you have concerns?
@Crown0815 I think we should also add some data in https://github.com/nunit/nunit/blob/master/src/NUnitFramework/testdata/TheoryFixture.cs with a Theory(true) and a Theory attribute in the same class and then a test in src/NUnitFramework/tests/Attributes/TheoryTests.cs that tests that the boolean affects the search.
| private readonly bool _searchInDeclaringTypes; | ||
|
|
||
| /// <summary> | ||
| /// Creates new DatapointProvider |
There was a problem hiding this comment.
| /// Creates new DatapointProvider | |
| /// Creates a new DatapointProvider. |
| /// <summary> | ||
| /// Creates new DatapointProvider | ||
| /// </summary> | ||
| /// <param name="searchInDeclaringTypes">Determines whether when searching for theory data members of declaring types will also be searched</param> |
There was a problem hiding this comment.
| /// <param name="searchInDeclaringTypes">Determines whether when searching for theory data members of declaring types will also be searched</param> | |
| /// <param name="searchInDeclaringTypes">Determines whether when searching for theory data members of declaring types will also be searched.</param> |
extension of feedback from mikkelbu
As suggested by mikkelbu
|
@mikkelbu I made the requested changes. Apparently, some of the tests I added are failing, but I am not able to get them to run locally. Could you please explain what I have to do so I can run these tests locally. They are not discovered by VSTest. |
Currently, there are some issues running the tests in VS directly. There is a possible solution here The tests are failing as reflection is trying to access the field |
Without the owning type members of nested types will not be resolved correctly when using `ProviderCache.GetInstanceOf(fixtureType)` since the `fixtureType` does not have the member in question.
|
@mikkelbu I could not get the local tests to run, but your proposed changes fixed the failing tests. I considered a specialized class to encapsulate some of the operations executed on the member but then went with the proposed Tuple since it was a quick fix. Please let me know what you think. |
mikkelbu
left a comment
There was a problem hiding this comment.
@Crown0815 I'm sorry. I completely lost track of this during the summer. I'll merge the changes now.
fixes #3856
We already have a working solution for the issue described in #3856 which I adapted to the existing NUnit Theory attribute.
Please let me know what I can improve to make this a viable contribution.