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

Wiki on ITestCaseData seems to be out of sync with the code #39

Closed
provegard opened this issue Apr 7, 2016 · 5 comments
Closed

Wiki on ITestCaseData seems to be out of sync with the code #39

provegard opened this issue Apr 7, 2016 · 5 comments

Comments

@provegard
Copy link

The wiki (https://github.com/nunit/docs/wiki/TestCaseData) reads:

Although any object implementing ITestCaseData may be used to provide extended test case information [...]

However, when I create a custom object implementing the ITestCaseData interface, I get:

An exception was thrown while loading the test.
System.InvalidCastException: Unable to cast object of type 'CustomTestCaseData' to type 'NUnit.Framework.Internal.TestCaseParameters'.
   at NUnit.Framework.TestCaseSourceAttribute.<BuildFrom>d__21.MoveNext()
   at NUnit.Framework.Internal.Builders.DefaultTestCaseBuilder.BuildFrom(IMethodInfo method, Test parentSuite)
   at NUnit.Framework.Internal.Builders.NUnitTestFixtureBuilder.AddTestCasesToFixture(TestFixture fixture)
   at NUnit.Framework.Internal.Builders.NUnitTestFixtureBuilder.BuildFrom(ITypeInfo typeInfo)
   at NUnit.Framework.Internal.Builders.DefaultSuiteBuilder.BuildFrom(ITypeInfo typeInfo)
@blachniet
Copy link

This appears to work fine in NUnit 2.x, but it's broken in 3.2.1.

@CharliePoole
Copy link
Contributor

@blachniet We accepted this as a documentation bug because the docs are incorrect, reflecting the V2 behavior of the interface.

I mention that so you will understand that this issue won't result in anything changing in the NUnit codebase. Currently, the quoted statement "...any object implementing ITestCaseData..." is incorrect for NUnit V3. There's no particular reason an extension can't return the classes we provide internally in the framework, or extend them, rather than creating their own implementation from scratch.

@blachniet
Copy link

Ok, thank you for clarifying that. Is TestCaseData the appropriate class to derive from?

@CharliePoole
Copy link
Contributor

If you want the fluent interface, yes. But if it's an extension that provides data it probably makes more sense to derive from it's base class, NUnit.Framework.Internal.TestCaseParameters. That's what all the NUnit attributes that provide test cases use.

@rprouse
Copy link
Member

rprouse commented Sep 17, 2017

I have updated the documentation for TestCaseData and TestFixtureData.

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

No branches or pull requests

4 participants