Top "Unit-testing" questions

Unit testing is a method by which individual units of source code are tested to determine if they are fit for use.

How to unit test abstract classes: extend with stubs?

I was wondering how to unit test abstract classes, and classes that extend abstract classes. Should I test the abstract …

java unit-testing testing abstract-class
Test class with a new() call in it with Mockito

I have a legacy class that contains a new() call to instantiate a LoginContext(): public class TestedClass { public LoginContext login(…

java unit-testing junit mockito
Running single test from unittest.TestCase via command line

In our team, we define most test cases like this: One "framework" class ourtcfw.py: import unittest class OurTcFw(unittest.…

python unit-testing python-unittest
Why am I getting an Exception with the message "Invalid setup on a non-virtual (overridable in VB) member..."?

I have a unit test where I have to mock a non-virtual method that returns a bool type public class …

c# unit-testing moq
How can I tell Moq to return a Task?

I've got an interface which declares Task DoSomethingAsync(); I'm using MoqFramework for my tests: [TestMethod()] public async Task MyAsyncTest() { Mock&…

c# unit-testing task-parallel-library moq
Using python's mock patch.object to change the return value of a method called within another method

Is it possible to mock a return value of a function called within another function I am trying to test? …

python unit-testing mocking patch
How to use ArgumentCaptor for stubbing?

In Mockito documentation and javadocs it says It is recommended to use ArgumentCaptor with verification but not with stubbing. but …

java unit-testing junit mockito
Mockito - difference between doReturn() and when()

I am currently in the process of using Mockito to mock my service layer objects in a Spring MVC application …

java unit-testing mockito
How can we run a test method with multiple parameters in MSTest?

NUnit has a feature called Values, like below: [Test] public void MyTest( [Values(1,2,3)] int x, [Values("A","B")] string s) { // ... } …

c# unit-testing nunit mstest vs-unit-testing-framework