Unit-testing Questions
Ad
how to stub fgets in C while using Google Unit Test
I have currently been assigned to do unit tests on some problems that i've done during an introductory bootcamp, and i'm having problems
How to apply 12 Factor App to Linux driver developing?
I'm an engineer currently developing linux kernel-mode drivers and user-mode drivers. when i came across the theory of
On which level should I start/stop writing tests?
So i started to use react-testing-library and i
How to test a REDUX action containg a time reference
Context i am currently testing some redux actions for my react application. one of these actions stores the time when some data was
How to download and compile external library only once with CMake?
I am using the unity testing library in my project. ideally, i would like to automatically download the source code from github and put it in the
How to mock React setState for API test
I have built a react component api that i would like to test. the api is independent of the react usestate hook for testing purposes. as such, my
How to call custom methods of React component while doing unit testing. I am using typescript
I am using react with typescript. can anyone tell me how to call the custom methods which is written in component inside unit testing. i
ReactJS Testing a helper method using jest spyOn
So i have the following helper method - import { formfielderror, formvalidationrules } from "../../../types/form.type"; const
Comparing React JSX to generated HTML with Jest/Enzyme
I have a file with mock data. here it is: export const data = { content: { // eslint-disable-next-line description:
angularjs factory wrapper around lodash not loaded in test
So i have the following: angular.module('common.lodash', []).factory('_', function() { _.additionfunctiononlodashthaticreated =
Ad
Unit Test the Routes
Let's say i have defined a route: routes.add(new route("users/{id}", new mvcroutehandler()) {
FlexUnit component testing patterns: use addAsync or manually initialize?
We've been using flex for about 6 months here at work, and i found that my first batches of flexunit tests involving custom components would tend
Checking the results of a Factory in a unit test
I have developed some classes with similar behavior, they all implement the same interface. i implemented a factory that creates the appropriate
ReactWrapper::state() can only be called on class components Unit Testing Jest and Enzyme
Writing unit testing in react using jest and enzyme. while checking with a component state , it throws an error "reactwrapper::state() can only be
Is it possible to mock an authenticated Firebase user, in order to run full testing with jest, while preserving the database rules?
I have a firebase realtime database set up with a bunch of basic rules revolving around basic user authentication: { "rules": {
Is it possible to unit test a class that makes P/Invoke calls?
I want to wrap a piece of code that uses the windows impersonation api into a neat little helper class, and as usual, i'm looking for a way to go
How can I test for an expected exception with a specific exception message from a resource file in Visual Studio Test?
Visual studio test can check for expected exceptions using the expectedexception attribute. you can pass in an exception like this:
Unit testing a timer based application?
I am currently writing a simple, timer based mini app in c# that performs an action n times every k seconds. i am trying to adopt a test
ASP.NET MVC Beta Project can't create controller tests properly in subfolder
I'm using vs2008 team suite, asp.net mvc beta, with testdriven.net installed. when i created my project from the template, it created a "tests"
Angular not setting correct form validation classes in tests
There seems to be an issue with angular applying validation classes in unit test environment. by validation classes i mean ng-valid
Should I test private methods or only public ones?
I have read this post about how to test
Ad
Understanding unit test constraints and NUnit syntax helpers
Me and a colleague are starting a new project and attempting to take full advantage of tdd. we're still figuring out all the concepts around unit
How to Unit Test Data Annotation Validators
I'm implementing the data validation validators as shown here:
package.json generation / npm unused packages
I'm introducing unit testing in my project and for this, i need to make myself a package.json file. first
Is there something like ZenTest/Autotest for Java and JUnit
I've used zentest and autotest to work on ruby projects before, and i used to using them for test-driven development a la
Defining custom actions in Selenium
I have a selenium test case that enters dates into a date selector made up of three pulldowns (year, month, and day). select
Set Pytest mock value to None
I have a main.py file which includes windomgr class, xvfb as a class attibute and two
lateinit property apiInterface has not been initialized kotlin.UninitializedPropertyAccessException:?
I am writing unit test for my viewmodel when i run test i am getting following exception lateinit property apiinterface has not
Trying vue-test-utils-getting-started with default config and Preset Not Found when run
I am trying to do a unit test by following the
How to stub URLSession in Swift?
I have been following this
Converting a home-brew test application to a standard unit test framework
I've got a lot of tests written for a piece of software (which is a great thing) but it was built essentially as a standalone test in c#. while
How do you mock Python Kubernetes client CoreV1Api
I am using kubernetes client: kubernetes my function:
Ad
Is there a way to define variables usable in all subtests in node tap?
I was wondering if there's a way to declare a variable before all the subtests in node tap js in order to use it in each one of them. something
Using assert for NaN in Javascript
I'm trying to use assert.deepstrictequal to test that my output is nan, as per the
Unit Testing the Views?
Any idea on how to unit test the views in asp.net mvc? i am sick of encountering the yellow screen of death when i launch my mvc project
How can I write a unit test for a controller class that uses winforms for views?
Has anyone been able to successfully unit test methods that are, by necessity, coupled to the system.windows.forms.form class? i've
How to check expected log in the middle of a running function using Jest unit testing?
I have this demo function: export async function myhandler( param1: string, param2: string, req: request, next:
How to test a JSONP method in a service - Angular
I am making a simple email subscription application for which i have written tests and things went fine as for now. in order to make
How to fix: 'TypeError: expected string or bytes-like object' when doing unit test on a views.py function
I'm writing a test for a function that returns a jsonresponse. the function works fine on the website but the test always raises a typeerror. it
Ant Design and React Testing Library
I have recently started using ant deisgn and really enjoyed working with it. however i seem to have stumble upon an issue that i am having
Github actions for specific php version error
I have a laravel project and i am trying to use using github actions. i already set my php version to 7.3 and i was always getting this kind of
Testing method which need log in
I want to testing some method like user (method need log in user). $user = user::find(1); $response =
Test prevProps in componentDidUpdate in React via Jest
Having following code: componentdidupdate(prevprops: jsoninputprops) { if (prevprops.value !== this.props.value) {
Ad
How to stub isFile from fs.statSync
I am writing a unit test for file and path manipulations, but i cannot stub isfile in fs.statsync(filepath).isfile() .
Null Pointer exception passed by test method
method that needs to be tested - located in analyticsserviceimpl.java class public void
How to properly mock a function that is imported in a package?
I try to test a package that i created and for that i need to mock subprocess.popen. i want to do this with the patch decorator but i can't
Spy using chai on exported function
I have this situation: user.js: var a = function() { function b() { return 5 } } module.exports = a
Testing a User model outside Laravel
Introduction i'm running a system with several microservices (9+). each is separate microservice is an instance of laravel. to
Why PHPUnit into Laravel return "No tests executed!" at execution feature tests
I have file tests/feature/invoicepaymenttest.php, he contains are three tests. first and second are tests is executed correctly. third test has
React testing using snapshots
I'm wondering, what's your approach while testing react component using jest snapshots. are you testing every component? how do
Laravel unable to test job with mocked Service and object. The Mockery spy fails to detect called method
I want to test my functionality of my job: namespace app\jobs; use illuminate\bus\queueable; use
How to fix 'window.URL.createObjectURL is not a function' when testing mapbox-gl in React?
I'm testing react component with mapbox, material-ui and custom styles. i use jest + enzyme for testing. i have problem:
Best way to handle a model relationship status/state when unit testing in Laravel 6?
I have the following unit test in laravel 6.x, using sqlite: <?php /** @var \illuminate\database\eloquent\factory $factory */
Python:How to implement multiple dynamic mock.patch functions?
I am trying to dynamically mock/patch multiple @property methods of a class in python i.e. class dog(): ... @property
Ad
python test coverage comparison with previous run
I am using coverage.py to check the code coverage of my unit tests, in form of html
How to use value which returned from controller? Testing controllers on NestJs
Controller and method for testing: import { controller, get, response, httpstatus, param, body, post, request, patch, delete, res
How to spy on a function called inside class object
I want to test if this.service.somemethod is called using jasmine spy. source file: // src.ts import {
PHPUnit: how to submit raw data to post request linking for testing in Lumen?
I am using the default phpunit that comes with lumen. while i am able to create a mock post call to my link, i am unable to find a way to feed raw
How to write test cases for switch condition in android kotlin
I need to write test case for the switch condition in kotlin. class.kt fun
Mockito verify fails in second unit test
I am using mockito together to junit to implement unit tests for a class in an android project.the problem is that i call
Should I refactor code for unit testing in mvp android?
I made an mvp application in kotlin and in each function of my presenter i call a view method so should i refactor my code for unit-testing or i
How to add unit test for a function that calls a function received in props
onsubmit = (e) => { e.preventdefault() const errors = this.validateform() if (!errors) { const { handlesubmit } =
How to use an android dependency in unit tests?
I'm currently trying out tdd, but cannot get my head around how to use android dependencys in my unit tests. i want to parse the json
How to assign promise then response to external variable?
I am trying to reuse a code which returns an auth token to test my protected endpoints. i tried returning the promise response inside a
Jest unit testing a function throwing error
I was trying to unit test a function in node which throws an error regardless of any condition. here is my node function definition.
Ad
Unit Testing CoroutineExceptionHandler
Hello i have this code that uses coroutines and i want to unit test it : my problem is that my exception is never catched by the
Append the HTML tag to the document. HierarchyRequestError: The operation would yield an incorrect node tree
I was testing my react/typescript project with jest + enzyme. when i created an html tag and appended it to the document, i got an error.
Python Unit Test - the else block doesn't execute, and if it does there is no logging
I am building a qa system in python and selenium. i implemented a cool logger module and i really like it. my system runs fine and logs everything
How do I fix 'return' outside of function when running a Node.js application?
Being relatively new to jest - and having just used it to good success in a pristine
vue-test-utils - how to handle $refs?
The situation i am trying to shallowmount a component, unsuccessfully. the component makes use of
How to test if an instance of a django model was created?
I am testing an api for a game and have some issues with a model. this is my model: models.py class
Unit Test (MultipartRequest in Flutter)
This is a method i was trying to write a test for. i just want to write a very simple test that would just verify that send() was
Mockito mocked function returned Null
I'm trying to learn flutter and got stuck on making the test using mockito. i'm trying to implement clean architect to the flutter tutorial
Missing stub error on Mockito in Flutter. Trying to use post of Dio
I’m trying to perform a post request using dio and test it with mockito. but i don’t know why this error is happening, someone knows what is
NodeJS: How to assert if event callback function was called using sinon
How can i test if a callback function from a event listener is called? for example, i have the following code where app.js initializes the
Mocking shelljs with Jest - [TypeError: shell.exec is not a function]
As mentioned in my previous question about mocking, i am new to jest and testing and i seem to be getting some curveballs. this time
Ad
Unit testing with Laravel assertDatabaseHas and a float column
Doing some tests on my laravel app and am running into intermittent failures due to one of my database columns being defined as a
Testing a Function by Passing Input Multiple Times
I'm learning go with tests. i ended up with the below program from the end of chapter 2 in "head first go". it gives the user
Why am I getting the following error: Enzyme Internal Error: configured enzyme adapter did not inherit from the EnzymeAdapter base class
I have set up jest and enzyme and can't get it to run. it complains about the enzymeadapter base class. i have tried
Jasmine test error - TypeError: Cannot read property 'hide' of undefined
I am using in .html & bsmodalservice, bsmodalref in component to display the pop-up modal open and close. getting error in jasmine on testing
How to test mongoose in NestJS Service?
I would like to test getfund() method from my service. i use nestjs that uses jest by default. i have no idea how to test this line
Stub not getting called inside .then()
I am working on unit testing an express application. i am trying to mock up my external dependencies (express, database, etc) and am close to a
Unit tests running in parallel in flutter when using GetIt
I am writing an flutter app and i am using getit for dependency injection. when i write unit tests, i do something like this:
How to mock events with sinon?
Here is my simple program where i'm trying to get user's data via ldapclient. i need to test it without internet connection so wondering how to
Make partial mock of class with Jest in NodeJS
I'm new to nodejs and came from php, where creating partial mock was easy. but i'm not able to accomplish the same with jest in nodejs. i
Mocktail: type 'Null' is not a subtype of type 'Future<Response>'
I've been trying to test my api provider following the
Where to put the MockK settings.properties file in an Android project?
We're using mockk for unit testing our android project. since we're almost always use mockk(relayed=true) we wanted to set it as
Ad
Shallow does not render wrapped component
Component.js <react.fragment> { state.data ? jsx : null } </react.fragment> export default withstyles(styles, {
How do I run an individual Flutter test in Android Studio (Win10)?
I'm using android studio on windows 10 to develop a flutter app. i can run a group of tests just fine, but when i try to run an individual test in
Mock different answers and exceptions after several calls with Mocktail
I was using mocktail for my unit testing and i could not find a way to
Test Case with laravel Dusk showing error 'users_email_unique'
I'm getting error as on below screenshot
reduxForm() Connected React Component Unit Test using Jest with NO Enzyme
I'm stumped in getting my jest unit test to pass. i have a class which provides a password form, containing the following:
Trying to mock a DLL in a python wrapper unittest
The problem i'm writing a wrapper for a dll in python, as it gets more complex i'd like to have a few simple unittests that check if the
Flutter ObjectBox - How to unittest?
I'm building my new flutter app with objectbox as db. how can i write an unittest in android studio? when i write a unittest that includes
sinon not detecting private function called inside promise
I am quit new to sinon and rewire. i am trying to check if private function was called with in promise. private function stubbed is getting
Build a Laravel App With TDD - Episode 4, InvalidArgumentException: Unable to locate factory with name [default] [App\Project]
I am deep in bug town here, can anyone help? i am following the tutorial line by line and have got as far as the unit test in the episode:
Laravel model factory make() bypass create() in foreign key object creation
I have a factory for customer class $factory->define(customer::class, function (faker $faker) { return [
Missing stub error on mockito in flutter. Trying to use setString on mocked SharedPreferences
I'm trying to mock sharedpreferences using mockito in my flutter project. here is the error log. package:mockito/src/mock.dart
Ad
How to test if a value is greater than in flutter test
I want to check if one value is greater than another value with flutter testing. i know that we can use expect to check if one value is equal to
How to unit test JSON result in Jest NodeJS?
My function i am trying to unit test is given as note : mypayload= payload.items i will give a json
Ad
Blog Categories
Ad