unit-testing Questions

4

Solved

Say I have the following Python UnitTest: import unittest def Test(unittest.TestCase): @classmethod def setUpClass(cls): # Get some resources ... if error_occurred: assert(False) @classm...
Combo asked 9/7, 2013 at 0:43

5

Solved

Suppose I have interface and implementation class that implements it and I want to write unit-test for this. What should I test interface or Impl? Here is an example: public interface HelloInter...
Transient asked 7/6, 2012 at 18:33

3

Solved

To be succint: class AutoMoqDataAttribute : AutoDataAttribute { public AutoMoqDataAttribute() : base(new Fixture().Customize(new AutoMoqCustomization())) { } } public interface IWeapon { bool ...
Arv asked 17/7, 2014 at 7:45

1

Say I have integration tests with signature like: [Fact] [Trait("Category", "Integration")] public async Task FooTest() If I want to run only unit tests, in dotnet core I can r...

9

I am trying to get a unit test written in Typescript using Jasmine to compile. With the following in my unit-test file, Resharper prompts me with a link to import types from jasmine.d.ts. /// &lt...
Shuck asked 16/6, 2015 at 9:22

2

Solved

I am trying to test my code using Kotlin. When trying to import the kotlin.test package, nothing appears. Do I have to add the dependency somewhere first? And how can I run my unit test afterwards...
Salmanazar asked 16/7, 2017 at 17:35

2

Solved

For my unit tests, I need to import kotlin.test to be able to use assertFailsWith. I believe I have the right files in my app build.grade file. Part of the file is: apply plugin: 'com.android.a...
Propertied asked 13/12, 2019 at 19:47

2

I have the following file I'm trying to write unit tests for: import { document } from '../../globals'; const Overlay = () => { console.log(document.getElementsByTagName()); // this outputs 'u...
Sanjuanitasank asked 26/9, 2017 at 16:32

4

Solved

Python's unittest discover does not find my tests! I have been using nose to discover my unit tests and it is working fine. From the top level of my project, if I run nosetests I get: Ran 31 test...
Ferric asked 23/2, 2011 at 9:20

7

I added a new Test target to my Xcode project. My project has Swift code and Objective-C code, and has a bridging header. Upon either adding the bridging header to UnitTesting's build settings, or ...
Libau asked 5/2, 2015 at 12:3

12

Solved

I want to write a test for controller. Here is test snippet: @RunWith(SpringRunner.class) @WebMvcTest(WeatherStationController.class) @ContextConfiguration(classes = MockConfig.class) public class...
Frowzy asked 9/1, 2017 at 13:6

1

I'm trying to unit-test an array that is set from an async service in the ngOnInit() function of my component. export class DashboardComponent implements OnInit { todos: Todo[] = []; constructo...
Kultur asked 31/5, 2017 at 21:28

4

Solved

I have a typeguard which checks the instance of a dependency. private isObjectOfA(obj: A | B ): obj is A { return obj instanceof A; } In the spec file, I have mocked the class A. jest.mock('./m...
Maharajah asked 17/8, 2020 at 14:43

2

Solved

I am looking at the Coverage report within the Measures tab of a SonarQube analysed C++ project. On that page my summary information is as follows: What are the differences between the "Lines to...
Tizes asked 19/9, 2018 at 12:2

5

For example, I have this method in UserService: @Override @Transactional public UserDto create(UserDto userDto) { User dbUser = userRepository.findOne(userDto.getId()); if (dbUser != null) ...
Smalls asked 9/7, 2018 at 14:20

19

Solved

I'm using slf4j and I want to unit test my code to make sure that warn/error log messages are generated under certain conditions. I'd rather these be strict unit tests, so I'd prefer not to have to...
Anhanhalt asked 10/1, 2011 at 18:45

16

I'm using JEST for unit testing my express routes. While running the yarn test all my test case are getting passed, but I'm getting an error Jest did not exit one second after the test run has c...
Amand asked 26/12, 2018 at 17:22

20

Solved

How can I be sure of the unittest methods' order? Is the alphabetical or numeric prefixes the proper way? class TestFoo(TestCase): def test_1(self): ... def test_2(self): ... or class TestFoo(...
Ladykiller asked 4/11, 2010 at 9:32

5

Solved

In java8 it was possible to access fields of class java.lang.reflect.Fields using e.g. Field.class.getDeclaredFields(); In java12 (starting with java9 ?) this returns only a empty array. This do...
Inflection asked 8/5, 2019 at 11:6

5

Solved

I'm having a pretty complex selectors structure in my project (some selectors may have up to 5 levels of nesting) so some of them are very hard to test with passing input state and I would like to ...
Sweetener asked 15/4, 2019 at 20:8

8

Solved

While running unit test for kotlin suspend method which uses withContext(Dispatchers.Main) the test method fails with below exception: My coroutine lib versions are kotlinx-coroutines-core:1.1.1 a...
Kassiekassity asked 9/10, 2019 at 12:17

8

Solved

I have two TypeScript packages, and one package (Package A) depends on the other (Package B). Each package has a unit test set up using Karma. When I run unit tests for each individually after inst...
Disequilibrium asked 6/4, 2019 at 14:32

5

Solved

I am wondering if there is anyway to stub the value of Build.Version.SDK_INT? Suppose I have the following lines in the ClassUnderTest: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BE...
Exterminate asked 28/6, 2016 at 10:52

2

I'm writing a java library foo which has a dependency on bar:1.1+. But library bar has changed quite a bit over the time, and I'd like to ensure my library is compatible with every version of bar (...
Emanative asked 11/8, 2015 at 18:11

17

I can't run my unit tests. I have the next error: Your project does not reference ".NETFramework,Version=v4.6.2" framework. Add a reference to ".NETFramework,Version=v4.6.2" in the "TargetFra...
Harriman asked 16/10, 2018 at 10:49

© 2022 - 2024 — McMap. All rights reserved.