nunit

Why will Visual Studio 2019 will not run my unit tests?

微笑、不失礼 提交于 2021-01-21 07:12:49
问题 I am seeing some very strange behavior for NUnit tests in VS2019, where the same solution works fine in VS2017. There are several NUnit test projects in my soultion. In VS2017 with the NUnit Runner extension installed, I can see all of my tests in the Test Explorer window and the "run all" button will work and run all tests. Some developers in my organization use Resharper instead of the NUnit extension and this works too. I have stopped using Resharper because as VS introduces more features,

Is it possible to have a [OneTimeSetup] for ALL tests?

匆匆过客 提交于 2021-01-20 16:35:32
问题 I'm using NUnit to run some Selenium tests and I've got a minor issue I want to see if I can get corrected. What's happening is that the [OneTimeSetUp] and [OneTimeTearDown] is running after each fixture finishes. What I want is to run [OneTimeSetUp] once when the tests are started, and the teardown to run once ALL fixtures have finished. TestBaseClass.cs public class TestBaseClass { [OneTimeSetUp] public void Init() { // Login } [OneTimeTearDown] public void TearDown() { Driver.Close(); } }

Is it possible to have a [OneTimeSetup] for ALL tests?

旧时模样 提交于 2021-01-20 16:34:37
问题 I'm using NUnit to run some Selenium tests and I've got a minor issue I want to see if I can get corrected. What's happening is that the [OneTimeSetUp] and [OneTimeTearDown] is running after each fixture finishes. What I want is to run [OneTimeSetUp] once when the tests are started, and the teardown to run once ALL fixtures have finished. TestBaseClass.cs public class TestBaseClass { [OneTimeSetUp] public void Init() { // Login } [OneTimeTearDown] public void TearDown() { Driver.Close(); } }

How to fix: NUnit unit tests not showing up in testing pad in Visual Studio Community (Mac)

旧巷老猫 提交于 2021-01-20 08:52:01
问题 In spite of adding NUnit from NuGet to an existing .Net Core project, no unit tests are being shown in the Test Pad. Note: I posted these images as links because I have too low of a reputation to post images. What's up with that? Project > Add NuGet Packages... Selected NUnit Package (3.11.0) and clicked "Add Package" Checked to see if added to solution Created a new empty class file within the solution Added tests to this class No tests show up in the test pad I've tried restarting Visual

How to fix: NUnit unit tests not showing up in testing pad in Visual Studio Community (Mac)

纵饮孤独 提交于 2021-01-20 08:50:45
问题 In spite of adding NUnit from NuGet to an existing .Net Core project, no unit tests are being shown in the Test Pad. Note: I posted these images as links because I have too low of a reputation to post images. What's up with that? Project > Add NuGet Packages... Selected NUnit Package (3.11.0) and clicked "Add Package" Checked to see if added to solution Created a new empty class file within the solution Added tests to this class No tests show up in the test pad I've tried restarting Visual

.net白盒测试

喜你入骨 提交于 2021-01-14 06:21:57
很久没写博客了,刚好这段时间空闲,做点记录 前提:最近部门需要白盒测试的工具,在网上也搜索了很多资料,国内很少有类似的资料(很少公司.net代码进行白盒测试),最后在国外(翻墙)网站查找到了部分资料 白盒测试中的 条件覆盖、逻辑覆盖....这里就不解释了 用到的开源工具:Opencover、ReportGenerator(这两个开源工具就不在这里介绍了,百度有介绍) 开发语言:C# 白盒测试范围:web站点、exe执行文件 运行OpenCover需要一系列参数,这里只说明几个主要的参数: -target:这是目标应用或服务的路径(名称),这里指单元测试工具的路径,支持NUnit和MS Unit -targetdir:目标目录的路径,如果target argument已经包含了一个路径,那么这个参数可以提供一个查找pdb文件的可选路径 -targetargs:target参数指定的应用所需要的参数(编译测试工程生成的一个dll文件或者EXE文件路径) -output:输出XML文件的路径,如果没有提供将在当前目录下生成results.xml, 该文件将用于ReportGenerator生成可视化的覆盖率报告 ReportGenerator所需要的参数: -reports:上述XML文件的路径 -targetdir:生成报告的目录 string sExecShell = " {0}

Using RunImpersonated for an HttpClient call fails for a NUnit test, but works in Console

让人想犯罪 __ 提交于 2021-01-05 08:53:45
问题 I need to have my tests run as a testing account. To accomplish that I setup to the following code to create a handle into my testing account: SafeAccessTokenHandle testAccountHandle; bool returnValue = LogonUser("TestAccount", "myDom.net", "pass", 2, 0, out testAccountHandle); I can then make a call to load a URL: HttpResponseMessage response = null; await WindowsIdentity.RunImpersonated<Task>(testAccountHandle, async () => { var url = "https://accounts.google.com/.well-known/openid

Why is the compiler giving an error because of a non constant expression when passing just a string array

雨燕双飞 提交于 2020-12-30 08:34:48
问题 When I pass a string array to a test function like this: [TestCase( new string[] { "1", "2", "3" }, 1 )] [TestCase( new string[] { "54", "508" }, 1 )] [TestCase( new string[] { "768" }, 2 )] public void someTest( string[] someStrings, int someNumber ) { //... } The compilation works fine. But, if I remove integer parameter like the follwoing code snippet shows: [TestCase( new string[] { "1", "2", "3" } )] [TestCase( new string[] { "54", "508" } )] [TestCase( new string[] { "768" } )] public

Async unit testing with NUnit and C#

帅比萌擦擦* 提交于 2020-12-13 04:00:37
问题 I have the following method I created it's nothing fancy just retrieves data from an HTTP server but it is an async method. public async Task<string> GetStringFromConsul(string key) { string s = ""; // attempts to get a string from Consul try { //async method to get the response HttpResponseMessage response = await this.http.GetAsync(apiPrefix + key); //if it responds successfully if (response.IsSuccessStatusCode) { //parse out a string and decode said string s = await response.Content

Async unit testing with NUnit and C#

泪湿孤枕 提交于 2020-12-13 03:58:07
问题 I have the following method I created it's nothing fancy just retrieves data from an HTTP server but it is an async method. public async Task<string> GetStringFromConsul(string key) { string s = ""; // attempts to get a string from Consul try { //async method to get the response HttpResponseMessage response = await this.http.GetAsync(apiPrefix + key); //if it responds successfully if (response.IsSuccessStatusCode) { //parse out a string and decode said string s = await response.Content