PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label mstest. Show all posts
Showing posts with label mstest. Show all posts

Sunday, October 9, 2022

[FIXED] How to run automation scripts in particular order in CI pipeline with Azure DevOps?

 October 09, 2022     azure-devops, continuous-integration, microsoft-test-manager, mstest, vstest     No comments   

Issue

I'm trying to run my selenium automation scripts in CI pipeline using Azure DevOps. I have configured Visual Studio test task to run my automation scripts by selecting test plan option.

Now it runs all my automation scripts which associates with test cases. But it does not take the order define in the test case.

How do we define the order to run test cases? Currently it is not running according to test cases order.

For Example: I have test cases: Test A, test B, test C. I want to run test in order B,C,A.


Solution

You may create a main test and use any order, something similar was considered here: Controlling execution order of unit tests in Visual Studio



Answered By - Shamrai Aleksander
Answer Checked By - Mildred Charles (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Friday, August 5, 2022

[FIXED] How do I check "no exception occurred" in my MSTest unit test?

 August 05, 2022     c#, exception, mstest, unit-testing     No comments   

Issue

I'm writing a unit test for this one method which returns "void". I would like to have one case that the test passes when there is no exception thrown. How do I write that in C#?

Assert.IsTrue(????)

(My guess is this is how I should check, but what goes into "???")

I hope my question is clear enough.


Solution

Your unit test will fail anyway if an exception is thrown - you don't need to put in a special assert.

This is one of the few scenarios where you will see unit tests with no assertions at all - the test will implicitly fail if an exception is raised.

However, if you really did want to write an assertion for this - perhaps to be able to catch the exception and report "expected no exception but got this...", you can do this:

[Test]
public void TestNoExceptionIsThrownByMethodUnderTest()
{
    var myObject = new MyObject();

    try
    {
        myObject.MethodUnderTest();
    }
    catch (Exception ex)
    {
        Assert.Fail("Expected no exception, but got: " + ex.Message);
    }
}

(the above is an example for NUnit, but the same holds true for MSTest)



Answered By - Rob Levine
Answer Checked By - David Goodson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing