question

vrushali-8354 avatar image
0 Votes"
vrushali-8354 asked PengGe-MSFT answered

The type 'TestContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.VisualStudio.QualityTools.UnitTestFramework

we need to access test context created by specflow project in one of the method , so we have written below code in specflow hooks.


     [BeforeScenario]
     public void BeforeScenario( microsoft.visualstudio.testtools.unittesting.TestContext  context)
     {
         InitializeSpecflow(context);
     }

InitializeSpecflow( microsoft.visualstudio.testtools.unittesting.TestContext context)
{

//Logic for context.TestName execution logic
}

but , when we pass specflow test context to method even if both test context are of same type (i.e microsoft.visualstudio.testtools.unittesting.TestContext )
it gives error as "The type 'TestContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.VisualStudio.QualityTools.UnitTestFramework"

vs-testing
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

PengGe-MSFT avatar image
0 Votes"
PengGe-MSFT answered

Hi, @vrushali-8354

Welcome to Microsoft Q&A!

You can try to add this nuget package: Microsoft.UnitTestFramework.Extensions

Sincerely,
Peng


If you have extra questions about this answer, please click "Comment". If the answer is the right solution, please click "Accept Answer" and kindly upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.