Skip to main content

All Questions

0 votes
3 answers
125 views

Should we test private data (static objects in this case) to make sure it maintains its structure?

I had a discussion at work about whether to unit test a private static object we're using as data for a public component. const data = { 45: { name: 'John' }, 2: { name: 'Patricia' }, 27: { name: '...
Jose Daniel Vivar Personat's user avatar
-2 votes
2 answers
3k views

Best practices around writing testable extension methods

I’m currently working in C# and I’d like to write and extension method against a type. There is a small amount of repeated logic between classes surrounding JSON deserialization, using the ...
RTT's user avatar
  • 1
-1 votes
1 answer
76 views

Unit testing a chain of network requests - how many tests?

I have some fairly complex code, that is a chain of API calls. The result of one call is the input of the next. class PaymentService { func pay(userId: String) async { let paymentSource = ...
Lord Zsolt's user avatar
3 votes
1 answer
1k views

How to test channel pipelines in Go

I use the "channel pipeline" pattern quite a lot in Go, which looks something like this: // getSomeNums spits out ints onto a channel. Temperatures, pressures, doesn't matter func ...
Tal's user avatar
  • 141
-5 votes
1 answer
104 views

Should code be refactored to be more unit testable or should a framework like PowerMock be used?

Assume there's some code that's already in production that needs some unit testing. Generally speaking, would you want to refactor this code that's already in production by adding things like adding ...
JobHunter69's user avatar
-2 votes
1 answer
504 views

What are the best practices for writing a long, multi-step process? [closed]

When writing a long process, i.e. one filled with many steps of business logic, what are the best practices for organising it? There are a few different options here that I can see: Just write a long ...
Tom Malkin's user avatar
-4 votes
3 answers
141 views

What can an assertion test that running the actual code cannot?

I'm currently learning Jest, Enzyme, Detox and testing in general, but I'm still trying to grasp the benefit of testing. From what I understand, testing is about creating hypothetical situations. Let'...
user avatar
0 votes
3 answers
233 views

Is is worth the time to create a list of manual regression tests for a legacy application?

I am part of a new dev team that is assigned to work on a legacy app. The app currently has no regression or automated unit, integration and system tests. Due to technical debt and convoluted ...
user avatar
2 votes
2 answers
369 views

How to organize my test functions? (Part II: Keepin' it classy)

What are the best practices to organize your unit tests in classes? I see different possibilities: 1) One would be to write one "container" class for each function you want test and then ...
l7ll7's user avatar
  • 263
-2 votes
1 answer
380 views

Unit Tests - correct approach to test system with multiple layers

I'm wondering about Unit Tests. Let say i got a code ( in C#, but language is not important here): public class SOT: ISOT { List<string> _internalCollection = new List<string>(); ...
Thaven's user avatar
  • 659
-1 votes
1 answer
956 views

What is a common name for a module being tested?

When writing unit tests, I want to reduce the cognitive load of the reader as much as possible. One thing I've noticed that bothers me is that the variable names of the thing that is being tested are ...
pascalwhoop's user avatar
1 vote
1 answer
277 views

NUnit specify TestCaseAttribute on implementation or create a test method

Based on this question about the correct usage of nUnit's TestCaseAttribute, I was wondering whether to specify the test case directly on the implementation or create test methods (as when using ...
user avatar
4 votes
5 answers
5k views

Is it bad practice to supply command line arguments for unit tests

I am on C++ and using gtest as the main framework. Say I have a edge detection function I want to test that takes an image as an input and returns the edge detected image. I have 3 images ready to be ...
user3667089's user avatar
8 votes
3 answers
4k views

Is it right to skip unit testing and go straight writing integration tests if there's no point of testing the unit in isolation?

According to Martin Fowler's article, https://martinfowler.com/bliki/TestPyramid.html It is advisable to write more unit tests than integration tests. Does this mean ideally that every unit of work ...
Xegara's user avatar
  • 191
86 votes
11 answers
12k views

Shouldn't unit tests use my own methods?

Today I was watching a "JUnit basics" video and the author said that when testing a given method in your program, you shouldn't use other of your own methods in the process. To be more specific, he ...
carlossierra's user avatar
  • 1,425

15 30 50 per page