NUnit Test Run Order

I just want to point out that while most of the responders assumed these were unit tests, the question did not specify that they were. nUnit is a great tool that can be used for a variety of testing situations. I can see appropriate reasons for wanting to control test order. In those situations I … Read more

Python library ‘unittest’: Generate multiple tests programmatically [duplicate]

I had to do something similar. I created simple TestCase subclasses that took a value in their __init__, like this: class KnownGood(unittest.TestCase): def __init__(self, input, output): super(KnownGood, self).__init__() self.input = input self.output = output def runTest(self): self.assertEqual(function_to_test(self.input), self.output) I then made a test suite with these values: def suite(): suite = unittest.TestSuite() suite.addTests(KnownGood(input, output) for … Read more

Mocking methods on a Vue instance during TDD

Solution 1: jest.spyOn(Component.methods, ‘METHOD_NAME’) You could use jest.spyOn to mock the component method before mounting: import MyComponent from ‘@/components/MyComponent.vue’ describe(‘MyComponent’, () => { it(‘click does something’, async () => { const mockMethod = jest.spyOn(MyComponent.methods, ‘doSomething’) await shallowMount(MyComponent).find(‘button’).trigger(‘click’) expect(mockMethod).toHaveBeenCalled() }) }) Solution 2: Move methods into separate file that could be mocked The official recommendation is … Read more

C# – Asserting two objects are equal in unit tests

You’ve got two different Board instances, so your call to Assert.AreEqual will fail. Even if their entire contents appear to be the same, you’re comparing references, not the underlying values. You have to specify what makes two Board instances equal. You can do it in your test: Assert.AreEqual(expected.Rows.Count, actual.Rows.Count); Assert.AreEqual(expected.Rows[0].Cells[0], actual.Rows[0].Cells[0]); // Lots more tests … Read more

Mocking Static methods using Rhino.Mocks

Is it possible to mock a static method using Rhino.Mocks No, it is not possible. TypeMock can do this because it utilizes the CLR profiler to intercept and redirect calls. RhinoMocks, NMock, and Moq cannot do this because these libraries are simpler; they don’t use the CLR profiler APIs. They are simpler in that they … Read more