Giter Club home page Giter Club logo

testfx-docs's Introduction

This repository is archived, content is moved to https://github.com/microsoft/testfx

Microsoft Test Framework "MSTest V2" Documentation

Welcome to the repository which contains content for the Microsoft Test Framework "MSTest V2" documentation. If you are looking for the Microsoft Test Framework "MSTest V2" product repository, you can find it here.

MSTest V2 API documentation is available here.

Documentation

Contributing

There are many ways to contribute to VSTest

  • Submit issues and help verify fixes as they are checked in.
  • Review the documentation changes.
  • Contribute new topics/information, or make changes to existing documentation.

Microsoft Open Source Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

testfx-docs's People

Contributors

abhitejjohn avatar airbreather avatar ancoope avatar ankit-arora-gh avatar bartsipes avatar bstoney avatar cvpoienaru avatar evangelink avatar geoffyoung avatar greenturtwig avatar haplois avatar harshjain2 avatar jayaranigarg avatar kant2002 avatar khilangoel avatar mayankbansal018 avatar microsoft-github-policy-service[bot] avatar microsoftopensource avatar nohwnd avatar pvlakshm avatar singhsarab avatar styxxy avatar vagisha-nidhi avatar zhiliangxu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

testfx-docs's Issues

Custom test attribute breaks ncrunch

Hi,

I use ncrunch for testing purposes and it seems to look for test like this :

[TestClass]
public someClass
{
   [testMethod]
   public void someMethod{
      //testExecution
    }
 }

but what I ultimately have is

[CustomTestClass]
public someClass
{
   [testMethod]
   public void someMethod{
      //testExecution
    }
 }

is there a way to have multiple [testclass] attributes to accomodate this or has anyone come across this and got a workaround?

Thanks
Carl

How to get Tfs Run id as TestContext.Properties["__Tfs_TestRunId__"] not available

Hello Team,

in the earlier version of MSTEST TestContext.Properties["Tfs_TestRunId"] gives the TestRunId, not able to find the way in MSTEST V2, please help.

TestRunId is required to query the TFS database for Test analytics.

I checked the API documentation, but not able to find right document, I am sure information must be there.
Please help.

Unable to test decimal values using DataRowAttribute

Currently we cannot use decimal values in the DataRow attribute.
[DataRow(1.4m, 2.7m)]

The solution suggested in Stackoverflow is to pass it as a string and Convert it to decimal. (https://stackoverflow.com/questions/43787007/using-decimal-values-in-datarowattribute)

Let's say I have an xml attribute of decimal type. Then to test that if I pass it as a string and then convert to decimal it will pass and I'm testing string rather than decimal. So this is not a good solution. Are there any plans to support basic datatypes like decimal in the DataRow attribute?

DataTestMethod vs TestMethod

I discovered today that [DataRow] can be used with together with [TestMethod], where I had the understanding that [DataTestMethod] was required.

Searching both the source code and docs, I'm a bit confused.

I've find no practical difference between the two attributes in the source code, but the documentation for [DataTestMethod] says that it is intended for data driven tests.
Then the examples for [DataRow] uses [TestMethod].

TestFX documentation is lacking remarks and examples

I'm not sure if this is rather a documentation or a product issue, but none of the documentation pages on TestFx I read so far contained a Remarks section, explaining relevant information like motivation, result, effect and example.

No focus on fields

Since chromedriver https://chromedriver.storage.googleapis.com/index.html?path=87.0.4280.20/ i'm having issues with the tests running in parallel.

Multiple browsers are opened, as expected.
But only one browser session is clicking and inserting values. Only one page is opening the url I think. The other pages go to the url when I manually select the session. Nothing in our code has changed.

Any ideas what it can be? Problem might have occured since V86.

It is working on edgeChromium 86.0.622.68

README.md MSTest V2 API documentation may point to wrong or outdated doc

I might be mistaken but if on the readme file we go the link provided by the the flollowing line:
"MSTest V2 API documentation is available here."

This is the actual link: https://docs.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.testtools.unittesting
The page opens with a selected Version of MSTest.TestFramework 1.32

Again, I mght be mistaken or confused but I was expecting to see this version : 2.12
Am I missing something?
Let me know if I can help with something?

Please publish release notes in the main repo's "Releases" instead of this text document

You're maintaining a Markdown file of release notes in this repository, separate from the code repository... this makes it difficult to consume a feed for package updates. Single files and source files, generally, cannot easily be watched without using the GitHub API. However, the GitHub releases page can be modified to expose an atom feed.

Turn this

https://github.com/microsoft/testfx/releases

Into this

https://github.com/microsoft/testfx/releases.atom

MSTest V2 doesn't output "TestCategory" to .TRX files (but V1 did/does)

Hello!

Using MSTest.Framework (1.3.2) and the following code:

       [TestMethod]
        [TestCategory("Instructor chosen Grading Category Goes Here")]
        public void Basic_Fail_2()
        {
            bool correctAnswer = false;
            Assert.IsTrue(correctAnswer, "This message will be displayed when the test fails");
        }

I can run the tests from the command line to generate a .TRX / .XML file that includes the following

<TestDefinitions>
    <UnitTest name="Basic_Fail_2" storage="c:\mikesstuff\pers\dropbox\work\website\courses\bit143\lessons\lesson_03\nunit_materials\do_not_upload\mstest_using_dotnetcore\mstest_using_dotnetcore\bin\debug\netcoreapp2.0\mstest_using_dotnetcore.dll" id="468bfd94-b2bd-e0b2-dfaa-b056c00e7ae3">
      <TestCategory>
        <TestCategoryItem TestCategory="Instructor chosen Grading Category Goes Here" />
      </TestCategory>
      <Execution id="4afac95c-6b8a-4996-85d6-c8087f2e3203" />
      <TestMethod codeBase="C:\MikesStuff\Pers\Dropbox\Work\Website\Courses\BIT143\Lessons\Lesson_03\NUnit_Materials\DO_NOT_UPLOAD\MSTest_Using_DotNetCore\MSTest_Using_DotNetCore\bin\Debug\netcoreapp2.0\MSTest_Using_DotNetCore.dll" adapterTypeName="executor://mstestadapter/v2" className="MSTest_Using_DotNetCore.NUnit_Tests_Basic_Demonstrations" name="Basic_Fail_2" />
    </UnitTest>

However, when using MSTest V2 the .TRX file includes only this:

  <TestDefinitions>
   <UnitTest name="Basic_Fail_2" storage="c:\mikesstuff\pers\dropbox\work\website\courses\bit143\lessons\lesson_03\nunit_materials\do_not_upload\unittestdemo_core3_1\bin\debug\netcoreapp3.1\unittestdemo_core3_1.dll" id="daba9da9-b9e4-3614-3841-237a64d89d56">
      <Execution id="73801b0b-bd2c-4b31-ac77-2fb1e0417270" />
      <TestMethod codeBase="C:\MikesStuff\Pers\Dropbox\Work\Website\Courses\BIT143\Lessons\Lesson_03\NUnit_Materials\DO_NOT_UPLOAD\UnitTestDemo_Core3_1\bin\Debug\netcoreapp3.1\UnitTestDemo_Core3_1.dll" adapterTypeName="executor://mstestadapter/v2" className="PCE_StarterProject.NUnit_Tests_Basic_Demonstrations" name="Basic_Fail_2" />
    </UnitTest>

(Note the missing TestCategory element, and therefore the missing TestCategoryItem child element(s).)

I'd love to be able to 'tag' tests using the TestCategory attribute and have that attribute be accessible in the resulting .TRX file

Cannot find ITestDataSource

May I know which version of MsTest.Framework has ITestDataSource defined? I am using 1.1.18 but cannot see that interface. Thanks.

DataRow execution is not working after 2.2.3 version in VSTest@2 task for Test plan

Hi Team,

Below is the code for data row execution.

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace TestProject1
{

    [TestClass]
    public class UnitTest1
    {
        [DataTestMethod]
        [DataRow(new[] { "Connector_1", "Connector_2", "Connector_3", "Connector_4", "Connector_5", "Connector_6", "Connector_7", "Connector_8", "Connector_9", "Connector_10" })]
        [DataRow(new[] { "Connector_5", "Connector_6", "Connector_7", "Connector_8", "Connector_9", "Connector_10" })]
        [DataRow(new[] { "Connector_1", "Connector_2", "Connector_3", "Connector_4" })]
        [DataRow(new[] { "Connector_2", "Connector_4", "Connector_6", "Connector_8", "Connector_10" })]
        public void TestMethod3( string[] b)
        {

            Assert.AreEqual(b.Length, 4);

        }
    }
}

When we execute using MSTest.TestAdapter & MSTest.TestFramework version 2.2.6

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.6.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.6.0" />

It was not reporting all data rows to test execution. See below the result which is executed into the pipeline


**************** Starting test execution *********************
Using new test platform for test execution
Microsoft.TestPlatform.VsTestConsole.TranslationLayer.VsTestConsoleWrapper instance will be created
Failed    TestProject1.UnitTest1.TestMethod3(System.String[])    TestMethod3 (System.String[])
Adding trx file D:\a\_temp\TestResults\VssAdministrator_WIN-O1PP9NTUSN3_2021-10-07_07_58_00.trx to run attachments
**************** Completed test execution *********************

If we use MSTest.TestAdapter & MSTest.TestFramework version 2.2.3 then it working as expected. Please see the below result for the execution in Azure Pipeline.

**************** Starting test execution *********************
Using new test platform for test execution
Microsoft.TestPlatform.VsTestConsole.TranslationLayer.VsTestConsoleWrapper instance will be created
Failed    TestProject1.UnitTest1.TestMethod3(System.String[])    TestMethod3
Failed    TestProject1.UnitTest1.TestMethod3(System.String[])    TestMethod3 (System.String[])
Failed    TestProject1.UnitTest1.TestMethod3(System.String[])    TestMethod3 (System.String[])
Passed    TestProject1.UnitTest1.TestMethod3(System.String[])    TestMethod3 (System.String[])
Failed    TestProject1.UnitTest1.TestMethod3(System.String[])    TestMethod3 (System.String[])
Adding trx file D:\a\_temp\TestResults\VssAdministrator_WIN-O1PP9NTUSN3_2021-10-07_08_02_50.trx to run attachments
**************** Completed test execution *********************

We are using VSTest@2 task in azure devops. Please see below task.

  - task: VSTest@2
    displayName: 'Test using test plans'
    inputs:
      testSelector: 'testPlan'
      testPlan: '23'
      testSuite: '24'
      testConfiguration: '3'
      searchFolder: '$(System.DefaultWorkingDirectory)'
      codeCoverageEnabled: true
      platform: '$(BuildPlatform)'
      configuration: '$(BuildConfiguration)'
    enabled: true
    continueOnError: true

Unable to test MS-Unit test in C# .net for below program, anyone help me!

I need some help in MS-Unit testing in C# .net program, I watched all of your youtube videos but....
So,
Below is my question, Please help!
Write Automated MS-Unit Test in C#.NET for the following C#.NET program. The program converts a decimal value into binary? (10 Marks)

using System;
namespace BinaryClass
{
class Program
{
static void Main(string[] args)
{
Program p = new Program();
Console.WriteLine("Binary Value of 4 = "+p.IntToBinaryString(4));
}
public string IntToBinaryString(int number)
{
const int mask = 1;
var binary = string.Empty;
while (number > 0)
{
binary = (number & mask) + binary;
number = number >> 1;
}
return binary;
}
}
}

Unexpected scenario

Hi guys, I'm following the implementation of the custom data source with the interface ITestDataSource as is described in the example but I found that the test method is returning more scenarios than the expected.

See the attachment.
image

So, Why I'm getting a 3rd one scenario without parameters if the GetData method only specifies two?

Multiple results in VS2017 test runner

When test method attribute is overwritten (exactly the way shown in example RFC3), if first test passes and the other tests are failing, visual studio shows test result as passed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.