xunit

xUnit async tests shows up as “External” in VS2015

こ雲淡風輕ζ 提交于 2019-12-20 02:52:46
问题 I have problems with all my async xUnit tests showing up as External in the Test Explorer in VS2015. They will still run when calling Run All in the test explorer, but as they are considered external almost all of the VS2015 integration does not work, e.g. the navigation (click in test explorer to get to test) is not working, the Run/Debug Tests in the context menu never triggers the test, test status icons doesn't show and Code Lens won't find these tests. The async tests are using the

Comparing Two objects using Assert.AreEqual()

送分小仙女□ 提交于 2019-12-18 12:47:13
问题 I 'm writing test cases for the first time in visual studio c# i have a method that returns a list of objects and i want to compare it with another list of objects by using the Assert.AreEqual() method. I tried doing this but the assertion fails even if the two objects are identical. I wanted to know if this method, the two parameters are comparing references or the content of the object, Do I have to overload the == operator to make this work? 回答1: If you are using NUnit this is what the

What is the community-preferred Ruby unit testing framework?

雨燕双飞 提交于 2019-12-18 11:45:30
问题 In the Java space, JUnit is predominately used and in .NET I believe nUnit is very popular. Is a community agreed upon unit testing framework for the Ruby world? Background: I ask because I am new to Ruby and want to practice TDD at same time as I learn Ruby. So far I've only played with Test::Unit. 回答1: You can stick to Test::Unit or you can have nice extensions to it using Shoulda or some cool contexts using Context. On the other side, if you prefer BDD then you can safely stick to RSpec.

Referencing standard dlls from a .NET Core XUnit project

人走茶凉 提交于 2019-12-18 07:03:47
问题 I am using the latest version of XUnit and I followed these steps to get the Class Library (.NET Core) project started. All other libraries throughout my entire solution are only using 4.6.1 so I changed the frameworks section in project.json to the following: { "frameworks": { "net461": { "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1-rc2-24027" } } } } and everything works fine inside of my solution. I am able to run tests and all references to other libraries work fine even though

Can't get XUnit tests to run with .NET Core

梦想的初衷 提交于 2019-12-18 03:34:15
问题 I'm porting a small library that I have on NuGet to .NET Core. I've created .NET Standard 1.6 class libraries for the main project and the tests, and copied over the code. I changed the unit tests to use XUnit attributes and asserts rather than NUnit. Other than that I pretty much followed the instructions in the documentation, thus I added the following NuGet packages: Microsoft.NET.Test.Sdk xunit xunit.runner.visualstudio Alas, (1) Test Explorer does not find my unit tests, and (2) when I

Display OpenCover results in TFS 2015 build Summary

痞子三分冷 提交于 2019-12-17 19:24:18
问题 I have generated my xml coverage file as part of CI build on the TFS server using vNext 2015 build definition. How would one display the results in the TFS 2015 summary ? Either using the xml report or the html generated using the ReportGenerator. 回答1: You need to convert the results produced by OpenCover to a format which can be parsed by TFS. One way to do this would be to use the OpenCoverToCoberturaConverter NuGet package. Once you have that, you can use the Publish Code Coverage Results

Python unittests in Jenkins?

纵饮孤独 提交于 2019-12-17 17:19:49
问题 How do you get Jenkins to execute python unittest cases? Is it possible to JUnit style XML output from the builtin unittest package? 回答1: sample tests: tests.py: # tests.py import random try: import unittest2 as unittest except ImportError: import unittest class SimpleTest(unittest.TestCase): @unittest.skip("demonstrating skipping") def test_skipped(self): self.fail("shouldn't happen") def test_pass(self): self.assertEqual(10, 7 + 3) def test_fail(self): self.assertEqual(11, 7 + 3) JUnit with

Entity Framework Core: Log queries for a single db context instance

我是研究僧i 提交于 2019-12-17 10:40:12
问题 Using EF Core (or any ORM for that matter) I want to keep track of the number of queries the ORM makes to the database during some operation in my software. I've used SQLAlchemy under Python earlier, and on that stack this is faily easy to set up. I typically have unit tests that assert on the number of queries made for a scenario, against an in-memory SQLite database. Now I want to do the same thing using EF Core, and have looked at the Logging documentation. In my test setup code I do as

Mock Verify() Invocation

僤鯓⒐⒋嵵緔 提交于 2019-12-17 05:14:07
问题 I'm unit testing to see if a method is called. [Fact] public void Can_Save_Project_Changes() { //Arrange var user = new AppUser() { UserName = "JohnDoe", Id = "1" }; Mock<IRepository> mockRepo = new Mock<IRepository>(); Mock<UserManager<AppUser>> userMgr = GetMockUserManager(); userMgr.Setup(x => x.FindByNameAsync(It.IsAny<string>())).ReturnsAsync(new AppUser() { UserName = "JohnDoe", Id = "1" }); var contextUser = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Name

F#: Why those two collections are not equal?

白昼怎懂夜的黑 提交于 2019-12-14 03:55:50
问题 Was writing some units using XUnit until that at some points I bumped into something surprising: let id = Guid.Empty let contact = { Name = { FirstName = "Marcel" MiddleInitial = None LastName = "Patulacci" } DateOfBith = new DateTime(1850, 12, 25) Address = { Address1 = "41 av 8 Mai 1945" Address2 = None City = "Sarcelles" State = None Zip = "95200" } PhoneNumber = { DialOutCode = 33 LocalNumber = "766030703" } Email = "marcel.patulacci@outlook.com" } [<Fact>] let ``Open an account...``() =