tagged [unit-testing]

MSTest cannot find the assembly

MSTest cannot find the assembly I was using MSTest and i use command mstest /testsettings:local.Testsetting /testcontainer:folder\obj\Debug\test.dll and this is the output, > Run has the following iss...

Mock objects - Setup method - Test Driven Development

Mock objects - Setup method - Test Driven Development I am learning Test Driven Development and trying to use Moq library for mocking. What is the purpose of Setup method of Mock class?

9 Jan at 16:23

Is it considered bad practice to use InternalsVisibleTo for Unit Test Code?

Is it considered bad practice to use InternalsVisibleTo for Unit Test Code? Sample code in framework's `AssemblyInfo.cs`: Is this a bad practice?

13 Nov at 15:8

Bogus.Faker: How to pick a random enum value

Bogus.Faker: How to pick a random enum value I'm using c# to create random test data for my unit tests. I want to know how to easily pick a ? Any suggestions?

15 Oct at 15:0

How to mock protected virtual members in FakeItEasy?

How to mock protected virtual members in FakeItEasy? Moq allows mocking protected virtual members ([see here](http://blogs.clariusconsulting.net/kzu/mocking-protected-members-with-moq/)). Is it possib...

18 Mar at 11:32

DeploymentItem not deploying files

DeploymentItem not deploying files I am using `MS unit testing framework` for testing my C# library. I have to open a file which I'm deploying using `DeploymentItem attribute`. But it is not deploying...

xUnit or NUnit? What advantages and disadvantages of each other?

xUnit or NUnit? What advantages and disadvantages of each other? What are the pluses and minuses of each framework, comparing to each other? How well they work with ASP.NET MVC? How well they support ...

6 Dec at 15:6

Automated Unit testing - why? what? which?

Automated Unit testing - why? what? which? I am a C# winforms developer with an experience of around a year. The only unit testing that I have been doing till now has been manual. I have thinking abou...

22 Aug at 14:35

Mock IEnumerable<T> using moq

Mock IEnumerable using moq Having this interface, how can I mock this object using moq? I get: > can not convert expression type IEnumerable to IMyCollection

27 Jan at 13:29

Unit Testing: DateTime.Now

Unit Testing: DateTime.Now I have some unit tests that expects the 'current time' to be different than DateTime.Now and I don't want to change the computer's time, obviously. What's the best strategy ...

C# unit test, how to test greater than

C# unit test, how to test greater than In C# how can I unit test a greater than condition? I.e., iIf record count is greater than 5 the test succeed. Any help is appreciated Code:

24 Nov at 12:50

PHPUnit: assert two arrays are equal, but order of elements not important

PHPUnit: assert two arrays are equal, but order of elements not important What is a good way to assert that two arrays of objects are equal, when the order of the elements in the array is unimportant,...

16 Nov at 11:3

When to use mocking versus faking in C# unit testing?

When to use mocking versus faking in C# unit testing? Can anyone come up with guidelines suggesting the ideal scenarios to choose mocking versus faking, i.e., setting up the essentials manually? I am ...

19 Oct at 20:42

How to read a text-file resource into Java unit test?

How to read a text-file resource into Java unit test? I have a unit test that needs to work with XML file located in `src/test/resources/abc.xml`. What is the easiest way just to get the content of th...

24 May at 07:58

Code coverage with Mocha

Code coverage with Mocha I am using Mocha for testing my NodeJS application. I am not able to figure out how to use its code coverage feature. I tried googling it but did not find any proper tutorial....

Run a single test method with maven

Run a single test method with maven I know you can run all the tests in a certain class using: But I want to run an individual method and -Dtest=classname.methodname doesn't seem to work.

Difference between SetupSet and SetupProperty in Moq

Difference between SetupSet and SetupProperty in Moq I understand that SetupSet is old way of setting up property in Moq. It's obsolette now but my intellisense shows both with none of them marked Obs...

31 Oct at 13:17

Using IoC for Unit Testing

Using IoC for Unit Testing How can a IoC Container be used for unit testing? Is it useful to manage mocks in a huge solution (50+ projects) using IoC? Any experiences? Any C# libraries that work well ...

How to convert an existing assembly to a ms unit test assembly?

How to convert an existing assembly to a ms unit test assembly? In Visual Studio 2010 Pro, how can I easily convert a classic assembly to a ms unit test assembly ? It there a flag to activate in the ....

How to create unit tests easily in eclipse

How to create unit tests easily in eclipse I want to create unit tests easily by just selecting method. Is there a tool in eclipse that does that. It should support templates. I should be able to crea...

27 Feb at 07:21

How to write a Unit Test?

How to write a Unit Test? I have a Java class. How can I [unit test](http://en.wikipedia.org/wiki/Unit_testing) it? --- In my case, I have class does a binary sum. It takes two `byte[]` arrays, sums t...

13 Dec at 07:8

What tools exist for testing multithreaded .net code?

What tools exist for testing multithreaded .net code? Are there any tools that can help find race conditions when testing multi-threaded .net code? I'm looking for something with similar capabilities ...

14 Oct at 08:41

How do I generate a stream from a string?

How do I generate a stream from a string? I need to write a unit test for a method that takes a stream which comes from a text file. I would like to do do something like this:

22 Oct at 22:4

Can you mock an object that implements an interface AND an abstract class?

Can you mock an object that implements an interface AND an abstract class? Is it possible to use [Moq](http://en.wikipedia.org/wiki/Moq) to mock an object that implements an interface and abstract cla...

27 Feb at 15:32

How to write unit test for private method in c# using moq framework?

How to write unit test for private method in c# using moq framework? I want to write unit test for private method in C# using moq framework, I've search in StackOverFlow and Google, but I cannot find ...

17 Apr at 08:32