Questions tagged [unit-testing]

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

0
votes
0answers
3 views

Cannot import custom module into tests or main server

I'm setting up Unit Tests and a Flask Server to test out some of my companies integrations i.e Virus Total API Key validation and I am having trouble importing some modules I scripted up. # tests/vt....
0
votes
0answers
7 views

Python: Unit Tests/ Integration Tests: Workaround for file pathes?

I have some unit tests and integration tests I need to run in a project. The problem I face is that sometimes files are read (as mock data) and dependent on where I start the test, the relative paths ...
0
votes
0answers
6 views

sinon stub does not recognise a call to a stub

This is the code to test: const AWS = require('aws-sdk'); const { APPLICATIONS, NOTIFICATION_FREQUENCIES } = require('./config'); exports.createHandler = ({ notificationService }) => async (...
0
votes
0answers
17 views

unit testing custom directive

I'm using material angular and I have a form with mat-checkbox. Above the checkbox there are terms of use and user must scroll the terms of use to bottom for enable the mat-checkbox which is disabled ...
1
vote
1answer
25 views

AssertThrows not throwing exception when going through Java Streams

So I'm writing unit tests in which I'm testing capability to blacklist and unblacklist users (which is a feature in my code that is itself working fine). Here's a sample command that works as ...
1
vote
2answers
17 views

Test method with okhttp3 call

I have a method in the service class that makes a call to an external api. How would I mock this okHttpClient call? I have tried to do so with mockito but no luck with that. //this is the format of ...
0
votes
1answer
14 views

How to user Python Mock side effect to return different value based on function being mocked

I have a common function that I want to use as a side effect for two different functions. Based on the function being mocked , they should return a different value. The code is: def sleep_three(*...
0
votes
0answers
5 views

Create Build/Pipeline using Jasmine/Karma to run Unit Tests

I am trying to configure VSTS to run my Unit Tests on check in. My environment consists of only js files. I push, via rest service, my files to a server, in which I login via the browser and test my ...
0
votes
0answers
7 views

How do I use table values in test description with Jest test.each?

I've been using jest's test.each feature to help keep my unit test code tidy. You can use tables to define variables in the test's description as well as in the test itself. For example, this code ...
2
votes
0answers
25 views

How to test function component with a react-data-grid

I have created a data grid with react using React-data-grid (link) My code is as follows: import React, { useState } from "react"; import ReactDataGrid from 'react-data-grid'; const ROW_COUNT = 20; ...
0
votes
0answers
11 views

Java class Controller test with Mock

I have a question about unit test, to be exactly with Mockito. I created MVC architectural pattern and I should test my controller, which works with inputing form console. In my test I wrote some ...
0
votes
0answers
13 views

How can I unit test, that one viewmodel sends to another viewmodel proper string?

In a view model's constructor I have a command declaration that calls a method: OpenGroupCommand = new DelegateCommand(OnOpenGroupExecute); And the method looks like: private void ...
0
votes
1answer
31 views

Unit test tasks run in parallel using QThreadPool

I am using QThreadPool to run tasks in my application in parallel. The tasks take the thread pool as an argument, so they can start new tasks. How can I write unit tests for the tasks and assert that ...
0
votes
1answer
18 views

AndroidThreeTen not working in unit test without robolectric?

I'm having trouble creating a unit test without needing robolectric. I am using AndroidThreeTen.init(this) in my code and when I run my test if I disable robolectric I get an error: org.threeten.bp....
0
votes
1answer
25 views

How to Mock IUrlHelper

Getting started with Unit Tests can be frustrating, getting stuck at every detail. Hope this will improve as I gain more experience. Now, how do I mock IUrlHelper for unit test? I have this simple ...
0
votes
0answers
15 views

Axios catch error Request failed with status code 404

i am setting up unit test with jest in my vuejs project. testing with login component and i have tested successful all the props, input, client validation, but when i test with axios request POST ...
0
votes
0answers
17 views

How to handle message error in Entity when using @MockMvc

I using @MockMvc test in spring controller but i have a question. How to handle message error when MockMvc test not pass method. Entity: @Entity @ApiModel(description ="All details about the ...
0
votes
0answers
7 views

How to set “view” in unit test using robolectric framework in android

How can I set "view" to assign seekbar in my unit test using robolectric framework? I tried something like this View mMainView; mMainView = new RelativeLayout(testActivity1.getApplicationContext()); ...
0
votes
0answers
6 views

How to deal with Error 0 in CakePHP Unit Testing?

Whilst trying to access my unit tests through the browser I encountered an error '0'. (See full error below). My cake application is inside a docker container, with another docker container running ...
0
votes
0answers
11 views

why Code coverage report is not showing in Visual studio solution of Jenkin Server [on hold]

I'am able to get the Unit Test code coverage report in local machine but the same when performed in the devops build server, I'm not getting the code coverage report. Please assist on this
0
votes
1answer
17 views

Angular Unit Test: Uncaught Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'logout'

I am always getting this error randomly for differennt tests when I enable my login.spec.ts tests. Uncaught Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'logout' I tried ...
0
votes
1answer
21 views

How to programatically edit iPhone accessibility settings during unit test?

My application supports dynamic fonts. When user changes font size in settings (Settings > General > Accessibility > Larger Text) and jump back to application then every label should be updated. It ...
0
votes
0answers
18 views

Mock EF dbContext async methods using NSubstitute 4.0

I got an error when trying to use NSubstitute on my DbContext. So far I used the EntityFramework.Testing package and the following code to set up my DbContext in the tests. It was quite simple, here's ...
0
votes
1answer
12 views

How should I include before do in minitest rails3.2?

What is the syntax for writing before do in minitest ? I am trying to write a test case using minitest in rails3.2. In development environment, we are loading this data using some background jobs. ...
0
votes
0answers
19 views

How can i mock a component async dependency with jest

I am testing a react-native component in which imports a dependency (named import and async) which performs some logic and just returns a boolean but i think jest is not waiting for it to finish. ...
0
votes
0answers
13 views

Python unittest patch using custom mock class

I am testing a relatively simple piece of code that uses two relatively complex object that requires disk access. The complex objects are from a library. I would like to mock these library objects and ...
-2
votes
0answers
15 views

How to write unit test for authguard in Angular 6

This is my authguard code. How to write test cases for authguard? I don't know how to write. How do I write for can-active method Jasmine test? I am using Angular 6 and create a fake backend. I posted ...
0
votes
2answers
30 views

Is there a way to test non-static methods with NUnit?

I'm working on incorporating some unit tests into an old C# poker game that I'm trying to refactor (for practice). I ran into some trouble when trying to test a non-static method and I couldn't find ...
0
votes
1answer
34 views

How to fix api json delete request

In following code, I'm trying to create a new category (name ='To be deleted') and then I want to delete it. first part of the code working fine and I can see new record in the database every time ...
0
votes
0answers
9 views

Mock Mvc can't validate with param @DateValid

I using mockmvc test my method with params date and validator it with anotation @DateValid but mock mvc can't validator. It test success when i input wrong date. StudentCOntroler public ...
1
vote
1answer
24 views

How to write unit test case for switch case in Angular 6?

I am new to write test cases for Angular 6, this is my service code. How to write test cases for switch case. I don't know how write this. import { Injectable } from '@angular/core'; import { ...
0
votes
1answer
23 views

Googletest never fails (where it should) with bazel test but works with cmake & clion

I am trying to use googletest with bazel and cmake. The cmake and clion works perfect as for the test part, it fails where it should fail and passes where it should pass. However, bazel test will ...
0
votes
1answer
16 views

How can i improve Codeception Code Coverage speed

Currently we have written some unit test for our php laravel 5.5 application using codeception. just for additional info, our laravel code base have around 200k LOC. For normal unit test run, we ...
0
votes
1answer
21 views

Testing components with Font Awesome Icons Module

I'm currently working in an Angular 6 project where I have imported several of the new font-awesome 5 icons using the Fort-awesome module for angular. As expected, by doing so now some of my Unit ...
0
votes
0answers
9 views

ViewModelLocator was not found in UWP / WinIot Core

App1 I have an UWP App which uses a ViewModelLocator class (No MVVMLight or Prism). The ViewModelLocator is integrated as resource in the App.xml and used in the DataContext of the View. Running this ...
1
vote
1answer
29 views

Need assist with JUnit testing

I'm brand new to JUnit so I'm having a bit of trouble. I'm currently running JUint 4, and I'm trying to write a test that is specifically supposed to fail, yet it keeps passing as successful. I need ...
2
votes
1answer
54 views

How do I write a test assuring a compilation error?

I want to prove that my API statically prevents an invalid usage by failing to compile. There is tooling for assuring that code panics at run-time (#[should_panic]), but I couldn't find anything for ...
0
votes
0answers
15 views

FFF (C mocking framework) - Disable fakes between test suits (use original functions when needed)

I've already issued this as feature request in FFF's github repository, but decided to ask here just to ensure I'm not missing possible trick. https://github.com/meekrosoft/fff/issues/74 Let's say I ...
-1
votes
0answers
11 views

How to mock a class which uses an external service?

I am trying to build some tests for my class which converts, based on the currency, an amount to euro. What should I set in mockito in order to simulate a call to an external service? All the times I ...
0
votes
0answers
21 views

How can I create an abstract test class with test methods and have inheriting test classes?

Suppose I have multiple classes implementing a single interface, while the inner execution of method can be different between implementing classes, outputs are the same. Is it possible to create a ...
0
votes
1answer
16 views

Why am I getting 0 coverage from Jest when running it from npm?

I'm trying to get code coverage numbers for a single Vue component, using Jest. Let's say my component is /var/www/html/path/to/Component.vue and its corresponding unit test file is /var/www/html/...
0
votes
0answers
18 views

How to run more than one test using unittest in pycharm?

I'm doing unit test for my project using unittest module. I'd like to do a class that has more than one test function for organization. Using Pycharm, sometimes it works, but not always. When I ...
0
votes
0answers
25 views

How to check state changing between two components after button click?

I have 2 components for this task.First one is my wrapper component and the second one is component for buttons. I am clicking one of the buttons of my button component and it changes state in my ...
0
votes
1answer
25 views

Unit testing: Prevent creation of duplicate objects

My professor gave us this homework exercise and has created a project with a bunch of unit tests. Our goal is to make sure we can pass those unit tests. We have three classes. A class called Person ...
1
vote
0answers
30 views

Need Help in writing unit test for this code

Hi I am new to testing and I am having trouble in writing a unit test for the code below 1. ViewModel interface UserLocationViewModelInputs { fun searchLocation(location: String) } interface ...
-1
votes
1answer
6 views

Difference between Tests and Coverage steps on CI Servers

I'we just start playing with setting thresholds when I run my coverage trying to force our team to apply to dedicated threshold standards. My question is this, is there any need for separate tests and ...
1
vote
0answers
18 views

Error : MissingRequiredParameter: Missing required key 'RoleArn' in params

I am trying to write a unit test case which is failing somehow. it(TEST_LABEL_CONSTANTS.MetricsHandler.BAD_REQUEST_MSG, function(done) { Metrics(event, (err, response) => { ...
-1
votes
0answers
17 views

How to pass context while unit testing

How to pass context to a function while writing unit test? I was passing context to my function startYourself for that I have used ArgumentMatchers.any() but that gives a null pointer exception in ...
0
votes
1answer
32 views

How to mock URL struct?

I am writing some code to be able to make testing easier. After researching, I found a good way of making URLSession testable is to make it conform to a protocol and use that protocol in the class I ...
0
votes
0answers
10 views

Stubbing a React Context Consumer with Sinon

I'm having some trouble using Sinon v5.0.10 to stub Context.Consumer from React's (relatively) new API. Even after I stub the context consumer, I'm still getting the value in the default context ...

http://mssss.yulina-kosm.ru