nunit

Nunit Tests order of Execution

…衆ロ難τιáo~ 提交于 2019-12-10 23:43:47
问题 This might seem a sily question to those who are well versed in autonmation but I am struggling with many things. Here's one: I am finding that the tests I created with Selenium RC in Visual Studio 2008 are getting run from NUnit in the alphabetical order of their names? What am I missing? Is there a way to organize the order in which the tests in Nunit are run? Thanks! 回答1: Technically, your unit tests should all be able to run independently of each other so ordering should not matter. I

How to run specflow feature files in parallel?

假如想象 提交于 2019-12-10 22:55:48
问题 I am using specflow with NUnit on Saucelabs. I need to run features files in parallel . But I read somewhere that you cannot run in parallel if you are using ScenarioContext/FeatureContext which I am currently using in almost every test scenario. Is it true ? If true , what alternative can I use for multi threading. Please note that there is no dependency between the features or between the testcases in features. Can anyone provide a code snippet to help me implement parallel execution.

MSBuild task for combining NUnit or MSTest XML results

夙愿已清 提交于 2019-12-10 22:18:30
问题 I have a set of NUnit XML result files (produced by xUnit.NET via the NUnitXml parameter to the Xunit.Runner.MSBuild.xunit msbuild task pretty much as in How do I get Team Build to show test results and coverage for xUnit.net test suite? and http://jonnekats.wordpress.com/2009/05/07/integrate-xunit-tests-into-your-daily-team-build/) The script publishes each of the test runs individually, which is slow as it pulls in all the TestResults artifacts each time. Thus I'd like to combine them into

Unit test failing only when run on the build server

﹥>﹥吖頭↗ 提交于 2019-12-10 21:04:06
问题 To aid unit-testing we have wrapped up the DateTime class in a delegate so that DateTime.Now can be overridden in a unit-test. public static class SystemTime { #region Static Fields public static Func<DateTime> Now = () => DateTime.Now; #endregion } Here is an example of its use in an xunit unit-test: [Fact] public void it_should_update_the_last_accessed_timestamp_on_an_entry() { // Arrange var service = this.CreateClassUnderTest(); var expectedTimestamp = SystemTime.Now(); SystemTime.Now = (

How do you disable PostSharp when running unit tests?

浪尽此生 提交于 2019-12-10 20:57:44
问题 I want my nunit tests not to apply any of my PostSharp aspects so I can test my methods in isolation. Can this be done somehow in the Test Fixture Setup, or can it only be done on a per project level? 回答1: You could set the 'SkipPostSharp' flag on the test build, so that it is not compiled into your binaries in the first place. 回答2: You can have a static flag on your aspect to toggle it on/off and check the status of the flag in your aspect implementation. Then in your unit test setup just

NUnit retry dynamic attribute

十年热恋 提交于 2019-12-10 20:40:06
问题 Hello I want to pass the number of retries dynamically from app.config value. The app.config has the following line: <add key="retryTest" value="3"/> And I have defined this variable: public static readonly int numberOfRetries = int.Parse(ConfigurationManager.AppSettings["retryTest"]); Finally I would like to pass that variable as a parameter to Retry NUnit attribute: [Test, Retry(numberOfRetries)] public void Test() { //.... } But I get the following error: "An attribute argument must be a

BadImageFormatException thrown when running NUnit tests on TeamCity

南楼画角 提交于 2019-12-10 18:57:07
问题 I have a unit test project using NUnit 2.6.3 using .Net 4.5. But in the teamcity build step configuration I only have runtime 4.0 available (even if other components of my solution are compile against 4.5) and when I run my unit test I get the following exception : [Step 8/9] System.ArgumentException: Specified NUnit error running tests in '[SANITIZED].UnitTest.dll' assembly Loading assembly is compiled for v4.0.30319, MSIL NUnit runner runtime is v4.0.30319, x64 System.ArgumentException: A

Nunit testing with Mock. Instance of Interface

做~自己de王妃 提交于 2019-12-10 18:55:22
问题 I have the following (simplified) code. public class Controller { private readonly IService _service; public Controller(IService service) { _service = service; } public async Task<IHttpActionResult> Create(MyObject object) { var result = _service.method(object); if (!result.Succeeded) { return this.GetErrorResult(object); } } } and SimpleInjector is used to inject the dependency between _service and its implementation class, like this: public static void Register(Container container) {

How can I run automated bdd UI tests using NUnit and SpecFlow in particular order driven by categories

懵懂的女人 提交于 2019-12-10 18:46:12
问题 I need help running an automated UI tests by Continuous integration. I have around 200 test cases but they are not written following some good practices and they are depending each other. I am a dev not a QA and I don't know what is happening in details so excuse me if i am not right for something. This is what i can see : 1. The tests are BDD 2. They are written with SpecFlow 3. NUnit is used as test executor The system is a bit complicated and it is hard to write tests without dependencies

Where are logs located while running NUnit?

让人想犯罪 __ 提交于 2019-12-10 18:29:19
问题 I'm running NUnit tests from Resharper. I want to track execution process so my question is where can I find logs produced by my application? I use NLog, logger output path is relative, e.g. logs\mylog.txt . 回答1: I have a similar setup with my current project and for the unit tests, my NLog output goes to \UnitTests\bin\Debug\Logs. The logger is set up as follows in NLog.config (this produces a daily log file): <target name="FileLog" xsi:type="File" fileName="${basedir}/logs/${shortdate}_log