unit-testing Questions

4

Solved

I have a piece of code in a test that checks that a list of results contains certain properties, using Hamcrest 2.2: assertThat(result.getUsers(), hasItem( hasProperty("name", equalTo(us...
Sexed asked 7/4, 2021 at 8:45

13

Solved

I have a function with a decorator that I'm trying test with the help of the Python Mock library. I'd like to use mock.patch to replace the real decorator with a mock 'bypass' decorator which just ...
Birkenhead asked 5/10, 2011 at 20:50

3

Solved

Is any options available to enable options in "Test->Analyze Code Coverage"? Is another way to run the code coverage result?
Proudhon asked 1/11, 2018 at 6:28

12

Solved

class HelloWorld(object): def say_it(self): return 'Hello I am Hello World' def i_call_hello_world(hw_obj): print 'here... check type: %s' %type(HelloWorld) if isinstance(hw_obj, HelloWorld): ...
Tendency asked 21/6, 2012 at 21:3

2

I want to unit test some ES6 classes that are stored as modules. However, when I try to run my tests, import triggers an error message: Cannot use import statement outside a module which means I ca...
Ummersen asked 24/5, 2020 at 12:17

3

I'm implementing a web-scraping script for a website which will collect some useful information. Script is implemented using Puppeteer library and is basically a set of instructions like: Start a ...
Nevernever asked 23/12, 2020 at 1:14

6

Solved

I am trying to write unit tests around my exception handling so that I can verify the my logger is properly logging the exception. I am using NSubstitute as a mocking framework and Microsoft.Extens...
Impasto asked 2/10, 2017 at 16:5

4

This article describes setting the VS Code settings to point the debugging target at the build output of the unit test project. I have therefore set mine like this: { "explorer.confirmDragAnd...
Hankypanky asked 24/5, 2019 at 9:53

5

Solved

I'm trying to generate coverage html file with PHPUnit. I get a warning: 'No filter is configured, code coverage will not be processed' and coverage file isn't generated. This is phpunit.xml file &...
Cordeliacordelie asked 17/9, 2020 at 14:54

10

Solved

I'm using MapStruct, mapstruct-jdk8 version 1.1.0.Final and defining abstract class that I inject via Spring. I'm looking at how to be able to test them via Junit Test ? I've basicaly a main mappe...
Oralee asked 24/7, 2017 at 8:13

1

I have a multi-module Android gradle project. project |- app |- module1 |- module2 Each of the modules contains unit tests, the app module also contains Instrumented Tests. Instead of taking...

8

Solved

I have a function that uses the current time to make some calculations. I'd like to mock it using mockito. An example of the class I'd like to test: public class ClassToTest { public long getDou...
Hunan asked 9/8, 2012 at 16:24

5

Solved

For the following code: import unittest class Test(unittest.TestCase): def test1(self): assert(True == True) if __name__ == "__main__": suite = unittest.TestSuite() suite.addTest(Test()) un...
Duplication asked 30/9, 2013 at 5:45

3

I am writing tests for endpoints which requires bearer token authentication, but I am getting errors trying to pass authentication errors to HTTP methods like client.post(url,data,**auth_header) I...
Torrell asked 17/1, 2019 at 18:55

3

Solved

I was recently looking over a co-workers code and I realized that he implements a jest function in a BeforeAll function at the top of the describe call, and then creates a data object in a beforeEa...
Stygian asked 4/2, 2019 at 13:19

2

Solved

Is there a way in eclipse (Helios) to package/export my JUnit test suites (or maybe even test cases if possible) as executable jars? I know how to generate runnable jars from projects with a main c...
Carrara asked 10/1, 2011 at 15:24

7

Solved

I'm trying to create a unit test for my service with a mocked DbContext. I created an interface IDbContext with the following functions: public interface IDbContext : IDisposable { IDbSet<T&gt...
Cristionna asked 21/9, 2014 at 14:24

5

Solved

I want to understand how to @patch a function from an imported module. This is where I am so far. app/mocking.py: from app.my_module import get_user_name def test_method(): return get_user_nam...
Deglutinate asked 21/4, 2013 at 17:48

2

Solved

Mockk added support for mocking global functions. However, when they have overloads there's a problem. For example if you try to mock delay() with mockkStatic(::delay) you encounter this error: Ove...
Preceding asked 16/8, 2022 at 9:44

59

Solved

I have a test class and below I have posted a sample test from the test class namespace AdminPortal.Tests.Controller_Test.Customer { [TestClass] public class BusinessUnitControllerTests { priv...
Ivanivana asked 19/8, 2013 at 10:3

2

I have a subproject where I put all my QTest unit tests and build a stand-alone test application that runs the tests (i.e. I run it from within Qt Creator). I have multiple test classes that I can ...
Voleta asked 23/6, 2016 at 9:18

2

My project requires unit testing. I am using constructor dependency injection in my controller. When I mock the injected dependency object in my unit testing project and call it in a test method. R...
Ruffi asked 6/7, 2021 at 18:7

9

Solved

I have a asp.net core application that uses dependency injection defined in the startup.cs class of the application: public void ConfigureServices(IServiceCollection services) { services.AddD...
Stefanstefanac asked 9/6, 2016 at 11:29

7

Solved

I'm writing a CAD application that outputs PDF files using the Cairo graphics library. A lot of the unit testing does not require actually generating the PDF files, such as computing the expected b...
Roxy asked 12/1, 2011 at 19:11

10

Solved

I'm puzzled with dependencies. I want to be able to replace some function calls with mock ones. Here's a snippet of my code: func get_page(url string) string { get_dl_slot(url) defer free_dl_slot...
Boil asked 3/10, 2013 at 19:47

© 2022 - 2024 — McMap. All rights reserved.