-
Notifications
You must be signed in to change notification settings - Fork 744
Attaching files to the test result #1670
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
Comments
The method you mention is part of the TestContext class in Microsoft's test framework. NUnit also has a class of the same name, but it has no relation to the MsTest class and doesn't have such a method. There is no facility in NUnit to attach files to the output. |
Thank you Charlie. |
There is no plan for it at this time. If you would like to change this issue into a request for such a feature, we can do that and re-open it. If so, you should explain in more detail how it would work. How are files created, where are they stored, etc. Are you asking that NUnit actually create the files or simply retain a reference to them? Of couse, we would have to accept the idea, prioritize it and schedule it for some release. |
Thank you for your response Charlie. |
Thanks for the idea. I'll reopen this. To take it further, however, we would have to figure out how it works for NUnit itself, not merely the adapter. I'm marking this as an Idea, which is what we call something that is not well enough defined to consider as a future feature. Maybe other folks will chime in with suggestions. Things we need to consider:
|
This feature is a must have. |
I'm changing this to a feature needing design, which is more solid than an idea. We still need to resolve the questions listed in my earlier comment. |
I guess it's either serialising the file in the xml, or keeping a referenced directory besides it. One leads to vast xml, general slowness, and the files requiring a specific interpreter, the other leads to the possibility of files being separated from the results, and the references broken. Which is the lesser of evils? I feel like with the former, the pain will outweigh the benefits of keeping everything in package - and having 'hopefully available' relative links will suffice.
For the GUI, something like the above interface looks nice enough, just hyperlinks to the attached file. The console, imo, should notify the user in the failed-test message that a file is available, and it's location. I imagine this will require someone to submit a PR, once the design has been worked out - @fredgate, you interested? 😄 |
We should look at how MSTest stores the files. I expect that the Visual Studio extension requires a link to the file on the drive. |
Seems like a reference in the XML is the way to go. For NUnit, the logical initial location is the work directory, which is where the XML goes by default. That resolves my first two points above. Answering my other points:
Seems like a good feature, which I would lean towards raising to normal priority. @rprouse Do you recall how Gallio handled attachments? |
What does an attachment element need to include in terms of attributes and elements? Something like this? <attachments>
<attachment description="Final screen shot">ScreenShot.jpg</attachment>
...
</attachments> I'm assuming it is a child of the test that produced it, so we have that info. Users may want to include multiple screen shots, hence the description. Anything else? What is the syntax for attaching something? Should we use TestContext? Should there be a way to associate it with an assert so that the attachment is automatically created on failure? Does somebody want to write a spec for this? |
👍
No, I've never used attachments. I like your XML format. Personally, I think we should start with adding attachments from the TestContext as it is the simpler route. We can then evaluate if we want to expand that out to Asserts. |
So With overloads for |
Maybe we have a spec already! |
Please raise the priority of this feature. It would be very helpful for our test reults summary to attach UI screenshots. Would be these attachments available in the build result inside VSTS (Visual Studio Team Services)? |
I think it is a good feature and I will publish attachments as build artifacts in TeamCity |
I hope nobody has forgotten about this. The would be a very helpful feature. |
I think the prior comments resolved all the design issues, so I'm taking off the design label and adding the implementation issue to Backlog. It's not so much that we have forgotten this as that we have a large number of things going on. As I mentioned in an earlier comment, normal priority items like this one are not scheduled as part of our release planning. It's up to some team member or outside contributor to get interested enough that they take it on. Hopefully, adding it to the backlog will motivate somebody to step up. Depending on your skills, that could be you! 😄 |
great feature! would be much appreciated. hopefully someone implements this soon 😄 |
I've just done a PR for the required framework functionality to implement this, in #2152. Given there's a few people tracking this issue, I'm planning to convert this issue to an Epic and track runner support, once we decide what to do there. Here's my thoughts: VS Adapter Console/NUnitLite GUI/Xamarin TeamCity Thoughts on all the above? @nunit/framework-team ? I'll make individual issues once we've decided the next steps. |
@ChrisMaddock Issues can be design issues as well so you could do one that says "Figure out how to support attachments in the gui" - same for any others where you are unsure. For the console runner, we do not currently show all tests, although that could be done. Any detail report can be handled by an extension or a custom XSL transform. The latter would be trivial to implement for anyody who is willing to do XSL coding. 😄 It could be a contributed transform. NUnitLite is tricky, since we want to keep it very light. However, one assumes that the users will name their attachments in an intelligent way and put them all in the same directory, so they should be easy enough to find. In fact, that works for the console runner as wel Once we have attachments, I think it's very easy to add them to the results we pass to Visual Studio from the adapter. |
I've created nunit/docs#197 and nunit/nunit3-vs-adapter#332 to cover the next steps. Regarding runner support - if the only current calls for this are integration with the VS adapter, I'm inclined just to implement it there, for now. It's a feature that fits better with graphical runners, then cli - and other runner support can always be added in the future, should people have a need. |
@ChrisMaddock I would love to see attachment support from the console runner. |
@kdubau - perfect timing! 😄 In that case, what would you want it to look like? What would be your use case? I could imagine adding an 'attachments' block of text to test failures/warnings, listing description and file path. One reason I was debating not doing this, is that I wasn't convinced many users would want to copy/paste a filepath out of their shell, to find the respective file. Would you disagree? The other issue to think about, is that the console currently only displays failed/warned tests, and not all tests. Should we create a third list of results ('Information'?) which shows all passed-tests-with-attachments? |
Maybe it would actually be ok the console runner only showing attachments for failed tests, as that's possibly all that's interesting in a console run. I'm imagining relevant log files for failures here, and such. |
@kdubau Rather than describing it here, I suggest you create a new issue in the nunit-console repo. |
@ChrisMaddock @CharliePoole I might have misunderstood the context here. I'm only interested in having the attachments referenced in the output XML - no need for actually displaying the attachment information in the console output. My use case is to have my CI system (Visual Studio Team Services) be able to upload the attachments listed in the XML as build artifacts (so it would just need a reference to the file on the local disk). I was concerned running tests via the console runner would not have the attachments in the XML, but upon reading further I don't think this was the question. Please correct me if I'm wrong :) |
Right... if we need "support" in the console, that would mean doing something more than simply saving the XML that comes from the framework. In the case of the nunit3 adapter, I guess @ChrisMaddock is defining what that will mean. |
Hey folks, is this work done or more pending? I couldn't find any open issues or PR's related to it. Apologies if I'm missing something but my test attachments still are not appearing in the VS Test Explorer as I expect. I am using NUnit3TestAdapter 3.8.0 from NuGet and the API Are my expectations wrong? |
@kdubau - Nope, this should be released in NUnit v3.7 and NUnit3TestAdapter 3.8. See nunit/nunit3-vs-adapter#332 for the implementation. This issue just remains open as I still haven't got round to adding the two sentences of documentation required... 😱 If it's not working, I'd first run your tests in NUnit console - and see if your attachment is recorded correctly in the results xml file. If not, open an issue in this repo, if it is, open an issue in the adapter repo, and we can investigate further. 🙂 |
@ChrisMaddock okay, issue created nunit/nunit3-vs-adapter#373 |
Thanks to motivation from @kdubau, I've finally documented this feature, and can close this Epic. 😄 |
Uh oh!
There was an error while loading. Please reload this page.
Hi guys,
I am new with NUnit and i am wondering that how can i add attachment file to output in test explorer.
In unit test, there is a method in TestContext class call AddResultFile that can do this.
is there anybody can help me out.
thanks,
giang
The text was updated successfully, but these errors were encountered: