unit-testing Questions

25

Solved

I have some unit tests that expects the 'current time' to be different than DateTime.Now and I don't want to change the computer's time, obviously. What's the best strategy to achieve this?
Infiltration asked 11/3, 2010 at 14:31

16

I'm trying to run a local unit test that depends on the context, and was following this guide: https://developer.android.com/training/testing/unit-testing/local-unit-tests#kotlin and I set up my pr...

10

I've having a strange problem with this test: deal.test.js import Deal from "../src/models/Deal"; import apiProducts from "../__mocks__/api/products"; describe("Deal"...
Retro asked 1/7, 2019 at 17:16

12

Solved

Is it possible to load environment variables from an env file for unit testing purposes in Jest? I'm looking to run a series of tests on it like so: // unit tests for env file describe('env', () =...
Protuberate asked 9/5, 2018 at 17:31

6

Solved

I'm trying to create unit tests to test some specific classes. I use app()->make() to instantiate the classes to test. So actually, no HTTP requests are needed. However, some of the tested funct...
Proposition asked 4/1, 2017 at 10:24

16

Solved

I need to simulate a test scenario in which I call the getBytes() method of a String object and I get an UnsupportedEncodingException. I have tried to achieve that using the following code: Strin...
Endocentric asked 3/7, 2009 at 12:55

7

I'm just a beginner in Python and programming in general, and have some questions about the unittest module. I have a class, and in the __init__ method I am doing some assertions to check for bad...
Chubby asked 15/6, 2009 at 17:10

24

Say I have a class with no equals() method, to which do not have the source. I want to assert equality on two instances of that class. I can do multiple asserts: assertEquals(obj1.getFieldA(), ob...
Vivl asked 27/8, 2012 at 18:15

3

I am writing unit tests for my component but having trouble in creating the instance of the component and showing following error, TypeError: Cannot read property 'patientId' of null  I have tr...
Bernadettebernadina asked 5/11, 2019 at 13:10

11

How to unit test a code that is running in executor service? In my situation, public void test() { Runnable R = new Runnable() { @Override public void run() { executeTask1(); executeTask2(); ...
Incomparable asked 24/9, 2017 at 18:54

4

Solved

i am using Nunit and Autofac's Moq to setup a test [TestFixture] public class SomeTests { [OneTimeSetUp] public void Initialize() { } [Test] public void SalaryCheck() { using (var mock...
Firm asked 21/7, 2016 at 14:33

4

Why is response.context None in the following tests? I've checked response.content and it is ''. if I remove the assertIsNotNone line I get a TypeError: 'NoneType' object is not subscribable def t...
Neoterize asked 25/11, 2014 at 20:26

6

How to configure JUnit 5 for Android unit testing? I tried: testCompile("org.junit.jupiter:junit-jupiter-api:5.0.0") But it doesn't work, when I run previous the simplest unit test: @Test publi...
Wampler asked 11/9, 2017 at 17:17

6

Solved

I want to test whether a function invokes other functions properly with minitest Ruby, but I cannot find a proper assert to test from the doc. The source code class SomeClass def invoke_function...
Gaspard asked 3/6, 2012 at 10:6

8

Solved

Unit testing conn() using mock: app.py import mysql.connector import os, urlparse def conn(): if "DATABASE_URL" in os.environ: url = urlparse(os.environ["DATABASE_URL"]) g....
Matriarchy asked 23/7, 2015 at 9:1

6

Solved

Consider this code: public class DummyClass { public List<? extends Number> dummyMethod() { return new ArrayList<Integer>(); } } public class DummyClassTest { public void testMoc...
Triboelectricity asked 9/9, 2011 at 18:59

10

I have 2 pyspark dataframe as shown in file attached. expected_df and actual_df In my unit test I am trying to check if both are equal or not. for which my code is expected = map(lambda row:...
Jacaranda asked 3/10, 2018 at 2:59

1

Solved

I have mock data that I want to use for both unit and instrumented test. To avoid repetition, I created a common directory testHelper and placed my mock data there. In app/build.gradle I did: sourc...
Hoehne asked 8/3 at 9:26

2

Solved

I recently discovered the Failures into Break-Points - option from googletest using the command line option gtest_break_on_failure or by defining the GTEST_BREAK_ON_FAILURE environment variable. I...
Florance asked 3/4, 2013 at 7:48

2

Solved

I'm trying to test a component that uses react-redux for state management. To test quickly I want to mock useSelector, like this: const templates = [ { id: ..., name: ..., ... }, { id: ..., ...

11

Solved

I need to test the following method: CreateOutput(IWriter writer) { writer.Write(type); writer.Write(id); writer.Write(sender); // many more Write()s... } I've created a Moq'd IWriter and I...
Kropp asked 15/5, 2012 at 13:53

5

I have this codepiece in my React component, which renders an HTML in the end: new Date(createDate).toLocaleDateString() My local machine and our build machine have different locales set, so the...
Dang asked 15/4, 2020 at 9:6

2

Solved

I am trying to unit test a method within my controller in my Web API using XUnit. The role of the method is to get a single title, by ISBN, from the database. The issue I came across during unit te...
Beaded asked 25/5, 2020 at 9:23

13

Solved

I've been getting na error in PyCharm and I can't figure out why I'm getting it: No tests were found This is what I have for my point_test.py: import unittest import sys import os sys.path.inser...
Sufficient asked 12/3, 2016 at 23:59

2

Solved

I’m working on a Rust library that provides access to some hardware devices. There are two device types, 1 and 2, and the functionality for type 2 is a superset of the functionality for type 1. I ...
Benzoin asked 28/5, 2018 at 11:56

© 2022 - 2024 — McMap. All rights reserved.