nunit

Selenium c# accept confirm box

大城市里の小女人 提交于 2020-01-09 10:40:11
问题 I have written an nUnit test using selenium in c#. All was going well until I have to confirm a JS confirm box. here is the code I am using: this.driver.FindElement(By.Id("submitButton")).Click(); this.driver.SwitchTo().Alert().Accept(); The confirm box appears after the submit button. The confirm appears and then disappears immediately but the form does not submit. The behaviour is the same regardless of the accept() line above. I am using Firefox v15.0.1 and selenium v2.24 I have tried

NUnit Testing: Failing to properly instantiate the test suite due to SetUp attributes

时光怂恿深爱的人放手 提交于 2020-01-06 20:15:15
问题 Good morning, As context, I am working in an automated test suite using nUnit 3.0.1 (with Selenium). The tests are being runned directly from Visual Studio 2013' Test Explorer. My problem is this: There is some Setting up functionality that I am trying to make automatic when starting to run the test suite. These are things that need to be done only ONCE for all the suite of tests, so using the [SetUp] Attribute for each test class is not what I intend. When I run the Tests however, my setting

Error while doing writing unit test case -Could not load file or assembly 'Oracle.DataAccess, Version=4.112.4.0

折月煮酒 提交于 2020-01-06 07:28:09
问题 We have a requirement to do unit testing using either MS Test or NUnit Framework for our C# code. There are many methods which includes DB call. When trying to do so, I am getting below error: *{"Could not load file or assembly 'Oracle.DataAccess, Version=4.112.4.0, Culture=neutral, PublicKeyToken=*******' or one of its dependencies. An attempt was made to load a program with an incorrect format."}* I checked the Oracle version to make sure there is no mismatch, but no success. Also read

c# mock return base method

点点圈 提交于 2020-01-06 07:14:31
问题 I am writing a unit test case with NUnit framework to test our code. The code has referenced to 3rd party libraries like below: class MyClass: BaseClass { public void override FunctionA() { var a = BaseFunctionB(); } } we don't have sourcecode for BaseClass , but the BaseFunctionB is non-virtual. I was trying to Setup(x=> x.BaseFunctionB()).Reteruns("my values"); but it doesn't allow. I just want to test the FunctionA in MyClass , I don't care whether it's correct in BasefunctionB . How to

How to use ScenarioStepContext in hook?

瘦欲@ 提交于 2020-01-06 06:13:27
问题 I am using SpecFlow with NUnit3 and am trying to access the step context within a hook. I am running the tests in parallel so not using any static instance contexts, but using the parameter resolving feature of SpecFlow. With a hook like below, the ScenarioContext instance resolves fine, but the ScenarioStepContext causes the binding to throw error: Primitive types or structs cannot be resolved: TechTalk.SpecFlow.Bindings.StepDefinitionType (resolution path: TechTalk.SpecFlow

How to use ScenarioStepContext in hook?

与世无争的帅哥 提交于 2020-01-06 06:11:41
问题 I am using SpecFlow with NUnit3 and am trying to access the step context within a hook. I am running the tests in parallel so not using any static instance contexts, but using the parameter resolving feature of SpecFlow. With a hook like below, the ScenarioContext instance resolves fine, but the ScenarioStepContext causes the binding to throw error: Primitive types or structs cannot be resolved: TechTalk.SpecFlow.Bindings.StepDefinitionType (resolution path: TechTalk.SpecFlow

NUnit test under mono

允我心安 提交于 2020-01-06 04:21:07
问题 I have a mut.cs as follows. using System; namespace ns { public class Arith { public int Add(int x, int y) { return x + y; } public int Mul(int x, int y) { return x * y; } } } I came up with a Unit test for this - mut_test.cs using NUnit.Framework; using System; using ns; namespace Unit.Tests { [TestFixture] public class ArithTests { private Arith m_arith = null; [Setup] public void Setup() { m_arith = new Arith(); } [Test] public void ValidateAdd() { int res = m_arith.Add(10,10); Assert

NUnit tests being ignored

五迷三道 提交于 2020-01-05 07:11:13
问题 I have the following test fixture class and for reasons beyond me NUnit decides to run all of the test classes around this one but not this one using System.Workflow.Runtime; using System.Workflow.Runtime.Hosting; using MyProject; using NUnit.Framework; namespace MyProject.Test { [TestFixture] public class MyProjectTests { private const string Description = "This is a test Description generated through UNIT Tests"; private ManualWorkflowSchedulerService scheduler; private WorkflowRuntime

System.IO.Abstraction can't find IStreamWriter

社会主义新天地 提交于 2020-01-05 05:26:05
问题 I am trying to unit test a method that calls StreamWriter, I am trying to use System.IO.Abstraction in order to mock StreamWriter however i can't find the interface on the last Nuget looked into the source code as well but have no idea what is the replacement for this, other stuff like FileInfo is working as expected. Thanks, 回答1: I was also looking for how to mock a FileStream via System.IO.Abstractions and couldn't see it initially. It's Hanging off the FileInfo Object. It results in

Why does returning a pointer with a method makes the test fail in debug mode?

二次信任 提交于 2020-01-05 02:25:30
问题 When I launch the following tests in Release mode, they both pass, but in Debug mode they both fail. [TestFixture] public unsafe class WrapperTests { [Test] public void should_correctly_set_the_size() { var wrapper = new Wrapper(); wrapper.q->size = 1; Assert.AreEqual(1, wrapper.rep()->size); // Expected 1 But was: 0 } [Test] public void should_correctly_set_the_refcount() { var wrapper = new Wrapper(); Assert.AreEqual(1, wrapper.rep()->refcount); // Expected 1 But was:508011008 } } public