testing

How do I stub a function that does not belong to a class, during a widget test?

…衆ロ難τιáo~ 提交于 2020-05-15 05:43:12
问题 I am creating a flutter app that uses the native camera to take a photo, using the official flutter camera package (https://pub.dev/packages/camera). The app opens up a modal that loads a CameraPreview based on the the result of the availableCameras function from the package and a FloatingActionButton which takes a photo when pressed. While creating a widget test for this modal, I can not figure out how to stub the availableCameras function to return what I want during tests. I tried using

Mockito, argThat, and hasEntry

萝らか妹 提交于 2020-05-14 19:50:08
问题 tl;dr: These tests don't compile because the type parameters don't match. What changes should I make to make them compile and run correctly? https://github.com/wesleym/matchertest I have some non-test code that calls into a service. It calls the service's activate method with a map parameter. public class Foo { private final Service service; public Foo(Service service) { this.service = service; } public void bar() { Map<String, ?> params = getParams(); service.activate(params); } private Map

Why TypeError: axios.create is not a function? When testing axios GET

Deadly 提交于 2020-05-14 18:35:51
问题 I'm trying to test my axios API functions in React. Found this question here: how do i test axios in jest which pointed to using axios-mock-adapter import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; import chatbot from './chatbot'; describe('Chatbot', () => { it('returns data when sendMessage is called', done => { var mock = new MockAdapter(axios); const data = { response: true }; mock.onGet('https://us-central1-hutoma-backend.cloudfunctions.net/chat').reply(200, data);

Why TypeError: axios.create is not a function? When testing axios GET

泄露秘密 提交于 2020-05-14 18:35:12
问题 I'm trying to test my axios API functions in React. Found this question here: how do i test axios in jest which pointed to using axios-mock-adapter import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; import chatbot from './chatbot'; describe('Chatbot', () => { it('returns data when sendMessage is called', done => { var mock = new MockAdapter(axios); const data = { response: true }; mock.onGet('https://us-central1-hutoma-backend.cloudfunctions.net/chat').reply(200, data);

Chaining pytest fixtures

杀马特。学长 韩版系。学妹 提交于 2020-05-13 18:09:37
问题 I've been unable to find the magic keywords to google this problem or find it in the pytest documentation. I'm looking to be able to setup my tests to combine multiple fixtures into a single fixture - or inversely filter fixtures from another fixture. An example will explain it much better: import pytest @pytest.fixture(params=[0,1,2,3,4,5,6]) def number(request): return request.param @pytest.fixture() def odd_number(number): if number % 2 == 1: return number else: return None # Skip (or some

How to test performance / load of a modern angular application

余生长醉 提交于 2020-05-12 11:32:18
问题 I want to load / performance test a web application which uses angular 6+ as the frontend-framework. The application is quite big and uses lots of wizards / modals etc. I want to do some "real" e2e-frontend-tests (not just testing API-calls, but also js-rendering etc.) What are the current state-of-the-art approaches and tools to test applications like this? To clearify, i want to do some real e2e performance test like e.g. open a browser in headless mode, open a wizard and get the time it

Exclude testing device from Firebase Analytics logging

|▌冷眼眸甩不掉的悲伤 提交于 2020-05-11 04:13:06
问题 I am sure that Firebase is counting all my development work too in its analytics. I open my app like hundred times a day to debug and test on a few devices, it's really skewing up my readings. I have used a function to get me a somewhat unique ID to represent my devices and ignored all its analytics through code. public static String getPsuedoID() { String m_szDevIDShort = "35" + (Build.BOARD.length() % 10) + (Build.BRAND.length() % 10) + (Build.VERSION.SDK_INT % 10) + (Build.DEVICE.length()

Status expected:<200> but was:<404> in spring test

允我心安 提交于 2020-05-11 04:04:30
问题 I have this class: package controllers; import static org.junit.Assert.*; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.util.HashSet; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.springframework.beans.factory.annotation

Status expected:<200> but was:<404> in spring test

白昼怎懂夜的黑 提交于 2020-05-11 04:03:49
问题 I have this class: package controllers; import static org.junit.Assert.*; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.util.HashSet; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.springframework.beans.factory.annotation

pytest: how to make dedicated test directory

我们两清 提交于 2020-05-10 20:55:47
问题 I want the following project structure: |--folder/ | |--tests/ | |--project/ Let's write a simple example: |--test_pytest/ | |--tests/ | | |--test_sum.py | |--t_pytest/ | | |--sum.py | | |--__init__.py sum.py: def my_sum(a, b): return a + b test_sum.py: from t_pytest.sum import my_sum def test_my_sum(): assert my_sum(2, 2) == 5, "math still works" Let's run it: test_pytest$ py.test ./ ========== test session starts =========== platform linux -- Python 3.4.3, pytest-2.9.2, py-1.4.31, pluggy-0