Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the equivalent test attribute for TestFixtureSetUp of Nunit in MSTest

Tags:

mstest

In NUnit we use TestFixtureSetUp what is the equivalent test in MSTest?

Thanks

like image 581
kumar Avatar asked Mar 25 '11 13:03

kumar


People also ask

What is test attribute used for in NUnit?

The Test attribute is one way of marking a method inside a TestFixture class as a test. It is normally used for simple (non-parameterized) tests but may also be applied to parameterized tests without causing any extra test cases to be generated.

What is difference between NUnit and MSTest?

MsTest is a native unit testing library that comes with Visual Studio from Microsoft. NUnit is an extra Nuget package that needs to be installed on top and interact with the APIs of Visual Studio. Nunit likely doesn't have direct integration into the native APIs like MsTest does.

Which attribute is used to run the test before each test method is called in NUnit?

This attribute is used inside a TestFixture to provide a common set of functions that are performed just before each test method is called.

What type of testing does NUnit support?

NUnit is an open-source unit testing framework for the . NET Framework and Mono. It serves the same purpose as JUnit does in the Java world, and is one of many programs in the xUnit family.


2 Answers

here you can find good table which shows NUnit and MSTest attributes side by side:

https://www.lambdatest.com/blog/nunit-vs-xunit-vs-mstest/

for your answer it's ClassInitialize attribute

like image 91
Robert Avatar answered Nov 14 '22 09:11

Robert


You're looking for the [ClassInitialize] attribute:

[ClassInitialize] public static void Initialize(TestContext testContext) { ... }  
like image 36
SLaks Avatar answered Nov 14 '22 08:11

SLaks