All Questions
Tagged with testing unit-testing
1,894
questions with no upvoted or accepted answers
21
votes
1
answer
5k
views
Run all UI/Unit tests from a multi-module project using a single command
We have a multi-module Android project, in which some modules contain UI tests and some contain Unit tests. We wish to run all UI tests from all modules using a single Gradle command and do the same ...
12
votes
4
answers
2k
views
How to patch/mock import?
I'm writing tests for airflow dag and running into issue mocking/patching the dag.
# dag.py
from airflow.models import Variable
ENVIRONMENT = Variable.get("environment")
# test_dag.py
import dag
...
12
votes
1
answer
12k
views
how to test if component rerenders after state change for react hooks testing library
I'm using https://github.com/testing-library/react-hooks-testing-library to test my component but not sure how to check if my component has been re-rendered after a state change in this test
const { ...
10
votes
2
answers
665
views
#[should_panic] doesn't accept constant as expected panic message
When running rust unit tests it is very useful to utilize the attribute macro #[should_panic(expect = )] to assert that the test is panicking with the correct error message (which means it's panicking ...
9
votes
0
answers
877
views
Angular Unit Test shows error warnings of kind NG0304 "component is not a known element" even after the component stubs have been declared
I am writing unit tests for an Angular component that uses multiple child components which are used with @ViewChild({}) in the following way:
Template:
...
<app-app-form></app-app-form>
&...
9
votes
0
answers
5k
views
How to use SpannableString in Android UnitTests
I just stumbled across a problem again where I haven't found a solution yet, so I thought I'd ask you :)
Suppose I have the following method (Kotlin):
fun getValue(): SpannableString {
val ...
9
votes
1
answer
5k
views
Autocomplete Mui Testing, simulate change doesn't work
I need to simulate an onChange event with enzyme to update a state's component that is not working, I share the component's code in order to be helped.
Component:
import React, { useState } from '...
8
votes
0
answers
3k
views
How to overwrite django CACHE settings in tests
I'm using django.core.cache.backends.dummy.DummyCache in my tests, however, there is one test which requires actual caching so I want to overwrite the CACHE setting for this one particular test. I ...
8
votes
1
answer
1k
views
Slow Grails test starting in Intellij IDEA
IDEA is starting a new Grails instance every time I wan't to run a single test.
Is there a way to use regular Grails runner but using interactive mode?
Running tests in interactive mode id blazing ...
7
votes
1
answer
1k
views
C# Unit Test: Retrieve Data from Repository
So I have to create a unit test for my data retrieve, the object i want to get is quite big.
I have repositories with "GetbyId" (in there we have the retrieve of the dataobject and the mapping).
I ...
7
votes
1
answer
826
views
Mockery: how to use shouldReceive with method_exists?
In my application code, I've got a method_exists check to authorize some hooking in a create process:
// Note: $myClass is implementing a ListItemFactory interface.
if ($isCreate) {
$methodName = "...
7
votes
1
answer
2k
views
How to optimize Grails build and test execution speed?
What are the techniques to improve the time taken for a Grails project to build and run its unit tests? For example, does Grails have an equivalent to the Maven 3 parallel build feature?
I am ...
7
votes
2
answers
4k
views
PHPUnit Data Provider Argument Count Error
I have just started using PHPUnit. So far, everything is going perfect except the Data Provider issue.
The problem is when I run test, it passes. But if I run it once again, it fails with the ...
6
votes
0
answers
1k
views
How do I stop all unit test if the first one fails?
I am having like 100+ unit tests for a project, but if a special condition fails in the first test, I want the other tests to stop, or to now even start executing. How do I do that?
6
votes
0
answers
2k
views
Unit Testing firebase in flutter throws Exception "No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp()"
I need to unit test an application that uses firebase. My unit tests always says "Unhandled Exception: [core/no-app] No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp()&...