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)

3
votes
2answers
50 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
31 views

Java Unit testing multiple test cases in one test

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?
-1
votes
0answers
16 views

Jasmine Test Case with owl Carousal [on hold]

How to test owl Carousel code with jasmine. Following is fiddle for same. $(function () { $('.owl-carousel').owlCarousel({ center: true, margin: 10, loop: true, autoWidth: true, ...
1
vote
2answers
195 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 ...
3
votes
2answers
102 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 ...
1
vote
2answers
410 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 ...
5
votes
1answer
107 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
0answers
44 views

All pair algorithm implementation [closed]

I need to know how to implement all pair algorithm in java... i am newbie for this kind of algorithm implementation .kindly help me with some suggestion. I have to generate possible test cases for ...
0
votes
1answer
69 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 ...
1
vote
1answer
51 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: ...
14
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 ...
22
votes
9answers
1k views

Is unit testing development or testing?

I had a discussion with a testing manager about the role of unit and integration testing. She requested that developers report what they have unit and integration tested and how. My perspective is ...
1
vote
1answer
72 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 ...
2
votes
1answer
164 views

How to introduce testing in the development cycle

In our company, we are only two IT staffs, and I'm the only developper. I'm developping rich intranet applications using plain php and extjs as javascript framework. Our development cycle is usually ...
9
votes
5answers
958 views

How to unit test a function that is refactored to strategy pattern?

If I have a function in my code that goes like: class Employee{ public string calculateTax(string name, int salary) { switch (name) { case "Chris": ...
1
vote
2answers
72 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
53 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 ...
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
404 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 ...
8
votes
5answers
576 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
124 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
277 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 ...
5
votes
6answers
473 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 ...
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
127 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
214 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
363 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
83 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
721 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
91 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
84 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
139 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
388 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
655 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
100 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
400 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
39 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
444 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
88 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
593 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
219 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
53 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
262 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 ...