Closed jacobwiseman closed 7 years ago
Hi @UltimateWombat
I will try to reproduce this issue.
But in general, test list is generated by splitting test's full name (where '.' is used as separator).
Probably it is just the NUnit creates full name for tests with TextFixtureSource
In any case, thank you for this issue, I will let you know about the results of my investigation.
On the TestHistory
tab, the test's Full Name is displayed as Quality.Automation.Tests.ClientApiTests(3,System.Collections.Generic.Dictionary'2[System.String,System.String],Quality.Automation.QueryObjects.ClientApi.MyObject.MyPayload,Quality.Automation.QueryObjects.ClientApi.Models.MyOtherObject.MyOtherPayload,Quality.Automation.QueryObjects.Tools.Models.ThirdPayload).testFindOrCreateSomething
Note that the majority of this Full Name is the input parameters. The actual test Full Name is simply Quality.Automation.Tests.ClientApiTests.testFindOrCreateSomething
. So in reality, anything between the parentheses should be ignored.
Hello again!
I think I found how to resolve this issue.
When you are using complex objects as structured data-driven test input NUnit generates Test full name by calling .ToString()
method for your object.
According to MSDN, the default implementation of the ToString method returns the fully qualified name of the type:
I've created sample tests to reproduce this: And as expected, I recieved wrong test list: Here is full name of the test:
Then I've added new .ToString()
method:
And new test list looked much better:
Because full name changed:
So basically you can try to override 'ToString()' method for your complex objects.
This works for custom objects, however if I am passing something like a Dictionary then the System.Collections.Generic.Dictionary
namespace is passes. I'd rather not have to extend the Dictionary class simply to overwrite the toString method.
Could you perhaps ignore any of the namespace strings between the starting (
and ending )
that designates the input parameters?
Yes, this is possible. Will do this with the next release for Ghpr.Core because this test list is generated by javascript controller.
Excellent, thanks!
Hello again! I am afraid we have some issues with this fix.
First of all, if we ignore any of the namespace strings between the starting (
and ending )
for our case, we can brake another cases like this (and for several cases for Ghpr.SpecFlow.Plugin):
Second one is related to test history. When our test is finished, we are creating Guid for our test. This Guid is created from test's full name, so we are expect this name to be unique. but for your case full name will not be unique.
So I think we need another approach for resolving this issue.
In the test.json file there are 2 fields in the json. name
and fullName
. It seems that if you could:
(
and ending )
from fullname
for organization & sorting purposes on the run-test-list tabname
field to display the test to the user. I don't see how this is any different than the original problem. If I was only sending in a complex object without a ToString() override before, then the fullName
was already non-unique.
Agree, this is what will be done.
I would suggest using override method to get unique test name.
Hi,
Using the new NUnit
TextFixtureSource
attribute AND feeding in complex objects as structured data-driven test input, the results as displayed in GHPReporter on therun-test-list
page.Instead of displaying the real test namespace hierarchy, GHPReporter is using the namespace of the input objects as well.