Testfx: No 'AddResultFile' implementation in TestContext on .NET Core 2.0 test project

Created on 30 Mar 2018  路  25Comments  路  Source: microsoft/testfx

Description

Using .Net Core 2.0 MSTest V2 project - I don't have access to some TestContext methods that are present on .Net Framework project.

Steps to reproduce

Create a .Net Core 2.0 MSTest project. Add TestContext property to a Unit Test class. Try to add a file to a TestContext using TestContext.AddResultFile() method

Expected behavior

There should be such method in TestContext class

Actual behavior

There is no such method in TestContext class

Environment

MSTest V2 1.2.0
.Net Core 2.0

enhancement up-for-grabs

Most helpful comment

Are there any workarounds or timeline for when this will be merged in?

All 25 comments

hi @Aecid,
you are indeed right the implementation for AddResultFile is missing for the net standard implementation of the TestContext Abstract class.

Here is the full CLR implementation

Here is the netstandard implementation that is missing this function

Please feel free to contribute. It's a very small fix and will mostly involve copying the same implementation and maybe adding a UnitTest or two.

I can help you out with the process.

Ok, I'll try to do this next week, thank you. :)

@Aecid have you started working on this? Or still working on it?
If no, I could take care of it :).
I'm facing the same issue, and I'm needing the AddResultFile method added to the TestContext.

@parrainc let me know if you need any help with the PR once you get started on it.

thanks @ShreyasRmsft
I'm already working on it, will let you know if i get lost with the PR. :)

Hi @ShreyasRmsft

I already implemented the AddResultFile method and GetResultFiles as well, created a couple of unit tests for both methods and pushed the commits to my repo.

But, the implementation for AddResultFile is not the same as in the full CLR implementation you provided, given that apparently the netstandard version used in the Shared project is lower than 1.3 (which not contains _Path.GetFullPath()_ method used to get the absolute path of the file name).

Please, kindly ask you to review [the implementation I've done in my repo] and suggests if there's a way to implement what _Path.GetFullPath()_ method does in a netstandard version lower than 1.3.

I'm just missing that in order to make the PR for this issue :)

Thanks in advanced!!

How would one add a result file to the test results while waiting for this feature?

@pvlakshm @PBoraMSFT to answer when this will be picked up from our side.

Are there any workarounds or timeline for when this will be merged in?

Why can't the caller be responsible for providing the full path?

@drewsac

Are there any workarounds or timeline for when this will be merged in?

In order to implement this (merge it into master branch), PR #411 must be merged. We're still working on that one, which has a pretty good progress but there are a few things (mostly validations) that need to be done.

Why can't the caller be responsible for providing the full path?

My understanding, the caller of .AddTestResultFile() should be able to specify both the full path or a relative path, not just the full path. That way things are easier for them, and if have a file in the bin/Test Result folders doesn't need to specify the full path, just the filename.

In any case, if the responsibility of providing the absolute path is shift to the caller, then the code in my repo must work as it, instead of depending of .GetFullPath() method.

Sorry I can't provide you with a specific date on when this will be picked up. Let's wait until PR #411 got merged, and as soon as that happens I'll make sure to open the PR for this important change.

Any progress on this? It is a couple of months later and this is still an issue.

@chrimc62 : Thank you for your patience. We have it planned for this quarter. Refer this to see our roadmap ahead.

@parrainc : We have added NetCoreTestContextImplementation seperately for NetCore Platform Service which targets netstandard 1.5, so implementing this feature should be pretty straightforward now.

We would love to have a contribution for this. Let me know if you need any help on this.

Wonderful news, I haven't noticed that change until now. I'm pulling master into my branch and fixing this one. Thanks for the heads up @jayaranigarg

Fixed as part of #609

Good morning. Should the AddResultFile be available for a NetCore2.2 project as well?

@bgoggan : Yes. It will be available. We haven't released the nuget packages with these changes yet. I can share early bits if you would want to try them out.

Ok, that's no problem. Do you happen to have any timeline on when the nuget packages will be available? We're still working on upgrading all our test projects to core so it's not an immediate rush for me to implement.

@bgoggan: We don't have a release planned as of now. We will definitely release one at the end of the Q2 quarter, checkout our roadmap. Early releases happens depending on need basis.

Ok, sounds good. Thanks for the information. I may contact you again to take you up on your offer of sharing the early pieces if that's still ok with you. I'll just see how things progress on my end with everything else.

Good morning @jayaranigarg: If possible, I'd like to take you up on your offer of sharing the early bits of the AddResultsFile changes to see if it's something I can temporarily handle until the official release. Just let me know. Thanks.

@jayaranigarg: thank you. I'll give that a shot.

Locking the thread as the issue is resolved from our end. Please feel free to create new issue if you need any help.

Was this page helpful?
0 / 5 - 0 ratings