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
1answer
25 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 ...
7
votes
5answers
994 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 ...
2
votes
1answer
263 views

Unit test storage on Android apps

I've been experimenting recently with Android applications. I've developed the convention (which I've seen used elsewhere) of placing my unit tests in a parallel source folder within an Eclipse ...
4
votes
2answers
401 views

What is the most appropriate testing method in this scenario?

I'm writing some Objective-C apps (for OS X/iOS) and I'm currently implementing a service to be shared across them. The service is intended to be fairly self-contained. For the current functionality ...
6
votes
5answers
507 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 ...
1
vote
2answers
387 views

Is there a better way to organize my module tests that avoids an explosion of new source files?

I've got a neat (so I thought) way of having each of my modules produce a unit-test executable if compiled with the -DTESTMODULE flag. This flag guards a main() function that can access all static ...
0
votes
3answers
116 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
267 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 ...
0
votes
2answers
91 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
443 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 ...
-3
votes
0answers
25 views

Visual Studio Team Test: How to unit test “?” operator with only Asserts() and not using any tool [migrated]

I need to write some unit test cases to test my code in C# Visual Studio Team Test framework. Below is the method I want to test: public static Association CreateAssociationFromXrm(Xrm.pv_association ...
0
votes
1answer
42 views

Is there a cleaner way to test extras_require

I have code reviewed a piece of Python code, but to me it looks really ugly, hacky and complex for something that can be achieved very easily. The code looks something similar to the following: ...
27
votes
2answers
1k views

How have Guava unit tests been generated automatically?

Guava has unit test cases automatically generated: Guava has staggering numbers of unit tests: as of July 2012, the guava-tests package includes over 286,000 individual test cases. Most of ...
2
votes
2answers
120 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
205 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 ...
10
votes
1answer
362 views

Does the games industry use automated testing for visual parts of games/rendering? How?

Some parts of a game are easy to test in an automated way (logic, maths, input handling); but there's also a lot that's purely visual and not easily testable. I would be surprised if the games ...
0
votes
3answers
74 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 ...
9
votes
3answers
701 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
2answers
74 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 ...
-1
votes
1answer
90 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 ...
8
votes
6answers
1k views

Do you really have to do BDD/TDD in a test first manner?

Even though I haven't been in a TDD or BDD project, or I have been in some that say they are doing TDD but are pretty far from it, these are things that I think about and really try to read as much as ...
0
votes
1answer
83 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
93 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
99 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 ...
13
votes
3answers
385 views

Orthogonality of unit tests vs. concision of unit tests

I'm writing unit tests for a steering system for a video game. The system has several behaviours (avoid this area because of reason A, avoid this area because of reason B, each adding a bit of context ...
9
votes
5answers
643 views

Are there any language agnostic unit testing frameworks? [closed]

I have always been skeptical of rewriting working code - porting code is no exception to this. However, with the advent of TDD and automated testing it is much more reasonable to rewrite and refactor ...
0
votes
2answers
96 views

Introduction to testing [closed]

I am very new to the concept of testing and I had not yet have any experience with this. At my company, no one does write tests as of now, neither is any test framework set up or anything. Also, we ...
4
votes
2answers
396 views

Looking for a very subtle unit testing example [closed]

In the context of Continuous Integration, I need to teach unit testing to a 20-people audience of programmers. Everything will be all right, but I am still trying to find the perfect unit testing ...
0
votes
0answers
38 views

Functional tests only to testing the infrastructure layer, or test too the domain services without mocking?

This is a code example: My entities (Domain Layer): class Account: def __init__(name, author): self.name = name self.email = email My repositories interfaces (Domain Layer): ...
0
votes
2answers
406 views

Unit testing in node.js and mocking modules

I'm trying to test this wrapper to request that I made: // lib/http-client.js var app = require('app'), request = require('request'); exports.search = function(searchTerm, next) { var options ...
0
votes
2answers
84 views

Handling repetitive unit testing tasks [duplicate]

This problem arose whilst writing a simple 3D vector class. The class contained methods (Java, so no operator overloading) for addition, subtraction, multiplication, and division. These methods ...
3
votes
6answers
460 views

Unit test private method in c++ using a friend class

I know that this is a debated practice, but let's suppose that this is the best option for me. I am wondering about what is the actual technique to do this. The approach that I see is this: 1) Make a ...
2
votes
1answer
217 views

Writing software without unit testing

Usually, when I write software, I use unit tests for each function to test if it is working without any problems. However, recently I have found myself writing some software that are not really ...
13
votes
3answers
1k views

How would you unit-test or perform the most effective automated testing on graphics code for OpenGL?

I'm writing a game and the accompanying graphics engine on top of OpenGL in C++. Im also a fan of good coding processes and automated testing. Graphics code + testing seems pretty immiscible, since ...
0
votes
0answers
50 views

Populate faked context for unit testing WPF ViewModels using entity framework

We're developing an entity framework based application which has about 20 different entities, with quite a lot of connections of various types (one-many, many-many etc) between them. Each entity also ...
3
votes
4answers
254 views

Convincing my boss that touching the Database is integration testing [closed]

I am currently working on introducing continuous integration and switching to git, and as part of that, we must also better structure our tests. We have agreed on splitting the tests in "integration" ...
67
votes
16answers
10k views

When is unit testing inappropriate or unnecessary? [duplicate]

It seems to be generally assumed (on Stack Overflow at least) that there should always be unit tests, and they should be kept up to date. But I suspect the programmers making these assertions ...
0
votes
2answers
115 views

Unit Testing large controller actions

I've a web page that has many constituent parts. On some user action, a POST operation is made, which then returns JSON to update the page. The problem is that this JSON payload contains a lot of ...
20
votes
12answers
3k views

How does unit testing work?

I am trying to make my code more robust and I have been reading about unit testing, but I find it very hard to find an actual useful use. For instance, the Wikipedia example: public class TestAdder { ...
12
votes
9answers
1k views

Should failing unit tests that we're not going to fix be removed? [duplicate]

My coworker likes to see all of our unit tests pass (as would anyone) and he argues that some of the failing tests of a system he wrote are unnecessary "noise" since they all involve the validity of ...
6
votes
3answers
790 views

How to unit test code that downloads a file from a github repo

This is my solution's structure: Storage.csproj > FileDownloader.cs > GitHubProvider.cs (implements IStorageProvider) > IStorageProvider.cs Storage.Test.csproj > ...
8
votes
2answers
205 views

Test Driven Development for Complex Games

I'm coding a game in my spare time, but I am mostly still a beginner when it comes to programming. I'm sorry if this question is off topic or if it ends up not being helpful to anyone else, but ...
0
votes
2answers
109 views

Is a mocking framework useful if I'm unit testing a repository/database? [duplicate]

I'm trying to improve my testing skills. I frequently hear about mocking framework to build fake objects (as far as I understand). Right now I need to test my repository (the usual add, remove, update ...
2
votes
2answers
98 views

Should “tests” be kept out of the main merge pipeline?

We all know sometimes a e.g. merge can go wrong. If our [unit / integration] tests are in the same repository as the merge, is there then a weakness there that if the tests have merged incorrectly ...
0
votes
0answers
48 views

Mixing newable and injectable in a Callable

I recently read http://misko.hevery.com/2008/09/30/to-new-or-not-to-new/ which discussed newable vs injectable objects. What would you do if you needed to make a Callable that talks to some service ...
24
votes
2answers
2k views

Unit testing classes that have online functionality

When unit testing functions of a class that has private functions that require online functionality. How would one go about testing it? For example: public class Foo { public int methodA() { ...
2
votes
2answers
83 views

Unit test database insert/remove and atomicity

I create my compact test database. This is a SDF file, embedded as a visual studio resource. When test suite starts this database is copied in %LOCALAPPDATA% so my test can use it. The first method ...
4
votes
4answers
313 views

Test-Driven Design is not Unit Testing [closed]

Ran across this statement by Martin Fowler circa 2002: Unit testing in XP is often unlike classical unit testing, because in XP you're usually not testing each unit in isolation. You're testing ...
16
votes
8answers
1k views

What are good unit tests to cover the use case of rolling a die?

I'm trying to get to grips with unit testing. Say we have a die which can has a default number of sides equal to 6 (but can be 4, 5 sided etc.): import random class Die(): def __init__(self, ...