xunit.net

xunit “could not load type” error

谁都会走 提交于 2021-01-28 19:44:17
问题 I inherited a project and the tests ran fine. Today, I created a new class, and xunit errors out when I try to use this class in a test. Both the test project and the app are targeting .NET Framework 4.6.1. I do clean and rebuild on the both the solution and the test project, but I still get the error. error: Could not load type 'MyNewClass' from assembly 'MyApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. project.json: "buildOptions": { "warningsAsErrors": true }, "testRunner":

Invalid cast exception Xunit deserialization error

守給你的承諾、 提交于 2020-06-29 05:13:09
问题 When trying to run a test case that uses the xunit framework through Visual Studio I am currently getting the following error. System.InvalidCastException HResult=0x80004002 Message=Specified cast is not valid. Source=xunit.execution.desktop StackTrace: at Xunit.Serialization.XunitSerializationInfo.GetValue[T](String key) in C:\Dev\xunit\xunit\src\common\XunitSerializationInfo.cs:line 40 at Xunit.Sdk.XunitTestCase.Deserialize(IXunitSerializationInfo data) in C:\Dev\xunit\xunit\src\xunit

How to run some tests only in azure devops CI env but not locally

余生颓废 提交于 2020-06-27 10:08:21
问题 I would like to specify some long-running c# project xUnit tests to only run in azure devops CI pipeline, but not when a click 'Run All' in Visual Studio locally (vs2019). Is there a 'best practice' for this kind of behaviour? I played around with making a test playlist and running that locally instead of Run All , but that would require updating the list (or lists) everytime i add new tests and this is error-prone. 回答1: The Skip property in FactAttribute is overridable - you can make a

Is it possible to use xUnit with LINQPad?

冷暖自知 提交于 2020-06-26 13:51:08
问题 Is it possible to use xUnit with LINQPad? It would be great to be able to write some tests for concepts being designed in LINQPad first. It's easier than adding yet another ConsoleApp23423894238 just to be able to quickly write some unit tests. 回答1: Possible? Sort of. This is neither a main use case of LINQPad nor of unit testing. Regarding LINQPad, you could use an existing test runner but probably the only ones that could be integrated with LINQPad are console runners. A test runner is not

ExecutionTimer.cs not found when stepping into code

半腔热情 提交于 2020-06-25 07:40:32
问题 I am writing some tests using XUnit framework and have to use some external code referenced through a dll. When I try to step into the method call, helper.GetEntity(), I get the following window and the execution exists. [Fact] public void PassingTest() { var datapointJson = File.ReadAllText(@"sample.json"); dynamic datapointObject = JsonConvert.DeserializeObject(datapointJson); // This is referenced from a different project in the same solution. var helper = new Helper.Actions(); var

How to setup Mock of IConfigurationRoot to return value [duplicate]

谁都会走 提交于 2020-04-29 10:23:27
问题 This question already has answers here : Expression references a method that does not belong to the mocked object (4 answers) Closed 2 years ago . I have used IConfigurationRoute to access a directory like this. if (type == "error") directory = _config.GetValue<string>("Directories:SomeDirectory"); _config is IConfigurationRoot injected in the constructor. I tried the following way to mock it. var mockConfigurationRoot = new Mock<IConfigurationRoot>(); mockConfigurationRoot.Setup(c => c