Unit testing is a method by which individual units of source code are tested to determine if they are fit for use.

learn more… | top users | synonyms (1)

0
votes
3answers
52 views

What does stubbing mean in programming?

I often hear the term stub, stub out somethings, stubs, ...etc. What does stubbing mean in programming, where the word come from? and in what contexts it can be used?(just examples)
5
votes
4answers
525 views

How to test a method which is not as much as a unit, because it is more of a 'orchestrator' / 'process' / 'controller' / 'coordination' class [duplicate]

I want to test a method which is not as much as a unit, because it is more of a 'orchestrator' / 'process' / 'controller' / 'coordination' class. This is the case: I have four unit tested classes: ...
-2
votes
1answer
19 views

SystemUnderTest versus other nomenclatures [on hold]

this is a minor issue but we are a worldwide company trying to unify some criteria and we are using systemUnderTest to name the variables used in our unit tests while others are using other ...
5
votes
2answers
291 views

Small code, big test

I have this code in a controller of an MVC implementation: public void execute() { try { String path = userSelectsFile(); if ( path == null ) return; //Just returns ...
8
votes
2answers
307 views

How much logic can be put into a command? Or differently: What kind of logic is command pattern for?

I have been using the command pattern for quite some time but I'm never really sure how much logic I can actually put in the Execute method. My current implementation of the command pattern looks ...
0
votes
2answers
150 views

Which language has most advanced support for proof based programming? [closed]

By proof based programming, I mean, you can somehow prove the correctness of your program without testing. I heard that Ada has a feature called contract, I also heard that, if you can pass Haskell's ...
2
votes
2answers
342 views

should I test this public method

I have the following simple implementation: var VALIDATION_TYPES = { ERROR: 1, WARNING: 2 }; var validationRules = {}; this.addErrorRule = function (event, rule) { ...
2
votes
2answers
142 views

When testing is it OK to use a method of the subject to test another method of the subject? [duplicate]

I have two methods in the same helper class one that creates an image (method A) and one that compares two images (method B). I want to check the return of method A against an existing image. To do ...
1
vote
2answers
145 views

How to add rigor to my testing?

I work on a small/medium sized Java application. Over time, I've tried to ensure that the tests which I write are "good" tests, and that there's plenty of them. Hence I've been looking into various, ...
-1
votes
2answers
99 views

Scheduling a Jenkins job to only run integration test [closed]

My current company has a Jenkins/DotCi setup. Our current process for CI is when dev pushes to github, jenkins runs unit tests on all branches and reports back to us via email if the unit tests ...
10
votes
4answers
1k views

Is there any value in writing a unit test that is a subset of another test?

To give a slightly contrived example, let's say I want to test that a function returns two numbers, and that the first one is smaller than the second one: def test_length(): result = ...
0
votes
1answer
105 views

Testing - How to test if you are actually testing the code?

I was thinking about unit tests and code coverage, and I came up with this thought: It is possible to have 100% code coverage and not test 100% of your code. For example: function ...
0
votes
1answer
47 views

Testing - Test for Specific Paths?

When (unit) testing, is is bad to expect the code to use certain paths. For example, should I be testing for specifically "/build/static/public/css/", or just that server.cssPath has been set to a ...
12
votes
5answers
1k views

This way I'm writing this code is testable, but is there something wrong with it I'm missing?

I have an interface called IContext. For the purposes of this it doesn't really matter what's it does except the following: T GetService<T>(); What this method does is look at the current DI ...
1
vote
0answers
101 views

How do I find which code is unused once my unit tests have been written? [migrated]

I'm developing unit tests to cover all of my code, but in IntelliJ IDEA the code no longer shows as "unused" because I have a unit tests which cover them. Is there a way to exclude unit tests from ...
1
vote
1answer
198 views

How to write unit tests for a piece of code that has a data context?

I am new to unit testing and using Microsoft's unit testing library for following piece of code. When I execute the code normally it executes fine, however when I run unit test written for this code I ...
3
votes
1answer
102 views

Unit testing a template class after refactoring

I am cleaning up my code by way of removing duplicates, and found two classes that were almost identical, out of 55 lines, only a single predicate in an if statement differed between them. Both ...
3
votes
1answer
78 views

Where does test fixture code fit in?

This is an unusual question since I don't believe it lends itself to typical software development practices but I hope you can prove me wrong. In MATLAB, my team have created several signal ...
7
votes
2answers
249 views

How do I unit test a heuristic algorithm?

Say we have our route finding algorithm: def myHeuristicTSP(graph): /*implementation*/ return route Now we want to unit test this: class TestMyHeuristicTSP: def ...
2
votes
0answers
96 views

How to test network connectivity API using TDD?

I'm currently trying to add TDD on my workflow. I fail to create tests where I can easily test a library that requires remote connections. More precise, my program uses snmp4j library. Currently I'm ...
-1
votes
1answer
57 views

Starting a big application with unit testing [closed]

I am learning test driven develeopment and read some books about TDD. I learned rules of unit testing. How can I write unit test, how can I select test method names, Act, Assert, Action and like this. ...
0
votes
2answers
118 views

Workaround for unit testing Core Data in Swift

I am still pretty new to programming, but my first app was recently approved and is now for sale on the App Store. My app uses Core Data and is written in Swift. After some initial difficulties, I ...
3
votes
5answers
197 views

How do you unit test a function that clears properties?

I have a very common function that I have always unit tested in the same way, but I'm wondering if there is a better solution or if it's even possible a code smell is involved. It seems like a very ...
0
votes
0answers
36 views

Using a mock Spring bean

I m actually introducting to unit testing with Junit and I am wondering if I m doing the things right. In fact, I want to test a service in which I inject a repository (a Spring bean in my case with ...
2
votes
2answers
263 views

Unit testing and reality [closed]

I m actually studying Unit testing, reading some articles on the internet and trying to understand how it works exactly, but it's not very clear for me actually. What should I test ? I have seen ...
4
votes
3answers
141 views

Test Driven Development when the specifications change

These days, it's fairly common for me to be tasked to make a change that actually breaks the prior spec. I know that one of the major ideas behind TDD is to have a suite that verifies all your changes ...
1
vote
1answer
47 views

Java Unit testing multiple test cases in one test [duplicate]

Is it good practice to have multiple test cases in one test or should I always create one test for single test case in every situation even if it is redundant? Why?
5
votes
1answer
129 views

How do you unit-test code using graphs?

I am writing (recursive) code that is navigating a dependency graph looks for cycles or contradictions in the dependencies. However, I am not sure how to approach unit testing this. The problem is ...
0
votes
1answer
75 views

Can JUnit be used to test this project?

I currently have an interesting situation occurring with my code, and after hacking away at what turned out to be a dead end for the last two weeks, I'm here asking those smarter than I to educate me ...
4
votes
2answers
130 views

Separate code coverage reports for unit and integration tests, or one report for both?

Should there be a separate code coverage report for unit and integration tests, or one code coverage report for both? The thinking behind this is that code coverage allows us to make sure that our ...
15
votes
3answers
1k views

How to test when arranging the data is too cumbersome?

I am writing a parser and as a part of that, I have an Expander class that "expands" single complex statement into multiple simple statements. For example, it would expand this: x = 2 + 3 * a ...
1
vote
1answer
136 views

Unit test approaches other than test-first and test-last? And what about variants of them? [closed]

I'm wondering if there are other approaches, old or new, to writing unit tests, and how viable they are, other than the traditional and tdd unit testing approaches. I know there is behavior-driven ...
1
vote
2answers
84 views

Should you mock key-value stores/aggregators

I've always been taught that your tests should run in isolation, and other than a db for ActiveRecord etc., your tests should not rely on any external software/services. e.g. I always mock my other ...
0
votes
2answers
54 views

Unit testing the variables passed to the view from the controller

Let's say I want to test a controller that gets some value from a service and then pass some of all of those values to the view. Do you test that the view gets the result that the controller took ...
8
votes
5answers
1k views

Sharing development test cases (unit and development integration) with the QA (test) team?

The testing team (the so-called QA team in some organizations) insists that the development team should share their (the development team's) test cases with them. Their arguments are that the ...
9
votes
4answers
688 views

How to do Test Driven Development

I have just 2+ years of experience in application development. In those two years my approach towards development was as following Analyze requirements Identity Core component/Objects, Required ...
0
votes
3answers
139 views

What's the idea behind mocking data access in unit tests [duplicate]

I understand that you're not actually supposed to hit the database or disk when doing unit tests... Why is that? Also, taking something like Moq, what is it actually supposed to mock and where? For ...
2
votes
1answer
286 views

2 questions about TDD

I'm just starting to get to grips with TDD, and I have 2 quick questions; I'm assuming that if I were writing software for a software company, that TDD would work alongside the software design? i.e ...
1
vote
2answers
213 views

Mocking the context of application

We have a context of the application which is a static class named Holder containing several static properties initialized by objects that are used throughout the application. All over the unit tests ...
5
votes
6answers
494 views

When should you start unit testing? (during which development stage?)

I'm currently learning about unit testing, specifically JUnit (with Java). Searching the web I see many threads talking about why you should use it, what type of methods you should use it with but I ...
2
votes
2answers
136 views

How much should I break up my unit tests?

I recently learned about unit tests and TDD and have started going back to add unit tests to my code (and thank god, it's proven that some things I've written are much more broken than I thought). ...
5
votes
4answers
227 views

Unit testing when it's harder to come up with concrete cases than write the logic

I have little experience with unit testing, but at the project we're working on right now we decided to do unit testing. The project is a WPF/Entity Framework application, and the part I'm being ...
0
votes
3answers
103 views

Unit testing method that calls multiple private methods

I've been reading a lot about unit testing recently and there seems to be a debate online about whether private methods should be tested or not. If I have an interface that exposes one method, but ...
0
votes
2answers
77 views

Should I put the name of the method I'm testing in the Unit Test method's name/assert message?

Given that a method's name might change in time, is it a good idea to specify the name of the method whose return value I am asserting as a part of the Unit Test method's name? What about the message ...
9
votes
3answers
756 views

In TDD should I have to write Test first or Interface first?

I am learning TDD using c#, as far as I know test should drive the development, that is first write a failing test after write the bare minimum code to pass the test then do refactoring. But it is ...
0
votes
1answer
87 views

when would you wrap a service object with an interface? [duplicate]

I'm new to UT and some of the best practices and anti-patterns when writing testable code, made me think. I used to wrap any service object with interface. but I see many mocking frameworks can ...
0
votes
0answers
54 views

when would you write static method as it avoid a “seam” for testing [duplicate]

when would you write static method. I used to write it in utils classes where all the methods are static and work state-lessly on arguments only. But now I know it blocks from creating a seam in ...
0
votes
1answer
95 views

Should I write a unit test to this?

Given the following pseudocode: List dohList = new List(); Foo foo = A.getFoo(); if ( foo != null ) { Bar bar = foo.getBar(); if ( bar != null ) { FooBar fb = bar.getFooBar(); ...
0
votes
0answers
225 views

Unit Testing: Pass in Modules or Entire Codebase?

In unit testing, the idea is (I think, correct me if I'm wrong) to unit test a module, then integration test these modules together, then integration test the respective "regions" of modules you ...
-1
votes
1answer
92 views

Do you spend your effort to reuse obsolete unit tests or rewrite them entirely? [closed]

I have this javascript project which has a unit test suite(about 200unit tests) that covers about 11.31% of the code that it was testing. The project has evolved greatly but the unit tests where never ...