nunit

How to handle multiple exception testing in nUnit 3 according to Arrange-Act-Assert paradigm?

♀尐吖头ヾ 提交于 2019-12-12 02:38:54
问题 In nUnit 3, there's been considerable changes made, among which the ExpectedException has been dropped to be replaced by the assertion model. I've found this and this example but the recommendation is to use Assert.That() instead so I want to use this approach as shown below. //Arrange string data = "abcd"; //Act ActualValueDelegate<object> test = () => data.MethodCall(); //Assert Assert.That(test, Throws.TypeOf<ExceptionalException>()); However, I'd like to test the assert for a number of

Specflow nunit test report is blank

拟墨画扇 提交于 2019-12-12 02:08:34
问题 I'm writing a Xamarin UI Test app via specflow. Im using Specflow nunit reporting to try and generate a test report I run the unit tests with "C:\Program Files (x86)\NUnit.org\bin\nunit-console.exe" path_to_project_dll I then run the specflow report within the directory of the testresults.xml file "path\specflow.exe" nunitexecutionreport path_to_csproj /out:path_to_html_output The output is a test report that recognises the features but doesnt give any information about the tests. Appreciate

NUnit crashing with NHibernate

依然范特西╮ 提交于 2019-12-12 02:01:00
问题 I'm running some NHibernate tests with NUnit and the NUnit test agent is crashing. I know there's not much to go on but obviously NUnit itself should not crash. Here's the stack trace... I don't understand what server it's trying to connect to or why, or why NUnit itself is crashing. I'm guessing it's an issue with my .hbm files, as NUnit crashes on my schema creation test which just contains this: var configuration = new Configuration(); configuration.Configure(); configuration.AddAssembly

Why is this test unit pass?

北战南征 提交于 2019-12-11 20:38:54
问题 I spend over 2 hours on this... i can't figure out why this test is PASSING. I mean.. it shouldnt return the view "Completed" but in the test it does! It say Expected "string.Empty" but returned "Completed" however for the creditcard to pass.. the securitycode need to be "test" which is isnt at all in the test. So it should return the default view (which is like view();). What i am doing wrong ? it is my test that is wrong ? or the controller logic ? Thanks a lots. [Test] public void Cannot

How does Cruise Control .NET use build / test tools?

允我心安 提交于 2019-12-11 20:28:37
问题 I am fairly new to CC .NET but have used other build tools in different environments (not C#) previously. My question is, when I choose NAnt as a Build Tool (for build scripts) & NUnit as a Test Tool (for testing) does CC .NET execute the command line for these tools with the parameters I specify in the config file? For example I have NAnt installed for my build scripts, will CC .NET execute NAnt.exe in the NAnt directory in order to build a project or does it do it by "other means"? Thanks.

faking API calls /w NSubstitute, for unit testing

岁酱吖の 提交于 2019-12-11 20:01:24
问题 I got a lot of function calls like the one below that I want to unit test but are unsure of how i should approach functions like these.. Do I just test it with the real URL and API calls?? but then it won't be a real unit test since I including things which I don't have control of... which leads me to the conclusion that I have to mock the RestClient out?? where I need to make a RestClient Foo(ApiUrl + ApiDirectory); which I can use NSubtitute on, is it the right way?? Would you guys approach

Unit Test to verify that WinForms application doesn't load Assembly more than once

旧街凉风 提交于 2019-12-11 19:35:36
问题 I am trying to write a unit test (NUnit) that will: Create an instance of some Form. Hook up the relevant AssemblyLoad event of the AppDomain to build a List of loaded assembly names. If the same assembly is loaded twice, fail. Otherwise - pass. I cannot seem to get the logic for this... The test always passes. Can this be done ? 回答1: It is hard to make your unit test fail. The CLR already makes sure that an assembly only gets loaded once. Pretty important, getting the same assembly loaded

Unexplainable code behavior with Unit test

匆匆过客 提交于 2019-12-11 19:34:30
问题 I have the following object (simplified port from Delphi) under a NUnit test using VS 2012. Public Class Class1 Private fLoaded As Boolean Private fSample As String Private Sub LoadFromDB() If (fLoaded) Then Exit Sub End If fLoaded = True ' fDataModule.LoadFromDB(Me) End Sub Public Property SampleProp() As String Get LoadFromDB() Return fSample End Get Set(ByVal value As String) fSample = value End Set End Property Public Property Loaded() As Boolean Get Return fLoaded End Get Set(ByVal value

How to Create a Unit Test for Adding Items in a Repository?

99封情书 提交于 2019-12-11 17:32:55
问题 I have an IUnitOfWork interface that encapsulates my custom repositories. My custom repositories in turn inherit from an IRepository interface. // The class that I am attempting to unit test // EmployeeBusiness.cs private readonly IUnitOfWork _unitOfWork; public EmployeeBusiness(IUnitOfWork unitOfWork) { _unitOfWork = unitOfWork; } public EmployeeDto AddEmployee(EmployeeDto employeeDto) { var employee = Mapper.Map<Employee>(employeeDto); if (employee == null) return null; _unitOfWork

how to ignore a RUN test

梦想的初衷 提交于 2019-12-11 16:28:31
问题 Assert.Ignore is used to ignore a test in Nunit. However, in my case I run tests, and if they have, for example, error code 2, I may choose to ignore the result for a while, but I still want it to be counted in the number of run test. But is there just a way to say the result is ignored, neither a failure or a success. In the *.xml I'd like to have result="Ignored" executed="True" 回答1: I use for now Assert.Inconclusive(), executed="True", so it's the closest to what I wanted. If someone finds