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)

4
votes
3answers
185 views

What kinds of bugs can integration testing actually find?

I feel like, in web dev at least, that integration tests can't really find any useful bugs. I can't think of any, at least. If I can use unit tests to verify that one section of my code calls a ...
3
votes
1answer
63 views

How do you properly test a complete software replacement

We have System A (an application and a database) that is built for a specific business department and therefore has business aligned data model and table structure. System A is a mission critical ...
2
votes
0answers
54 views

Dealing with conditional verification logic using guard assertion

I have parametrized test with 2 variants: NULL value and any NOT NULL value From this value is depends one assert: In case NULL it should be checked if object has field1 with value1 In ...
2
votes
2answers
147 views

Are DDD aggregates a good boundary for unit testing?

An aggregate can represent a somewhat stable system boundary. Does it make sense to write input and output test aggregates to do most testing? In theory we could use an aggregate as a data driven way ...
4
votes
1answer
214 views

How to Structure Simple C++ projects for TDD

I am introducing Google Test into our development environment at work, and would like to encourage a TDD mindset, making this as accessible as possible for new developers to start using. I am looking ...
3
votes
1answer
102 views

Unit testing a large project with few publicly accessible components [duplicate]

I'm asking about C#, but this probably applies to most other languages as well. Imagine I have a project with a lot of complex logic, split up into a lot of small components. Let's say that, among ...
1
vote
4answers
131 views

How and where to test if the JSON request objects generated by the front-end is valid

We have built a complex Angular application that sends multiple HTTP request to a REST service that is also built in house. Since both the frontend and the backend is being developed in parallel, ...
0
votes
0answers
85 views

Testing $stateChangeStart

I'm trying to figure out how to test my $rootScope.$on.$stateChangeStart event. Authentication service already has unit tests to check it's functionality, but I'm really trying to do is set up a test ...
2
votes
1answer
133 views

Using Spring in Java Project

I've got a question about a correct usage of Spring. I know that some people use the DI "aggressively" so that they always use spring and completely eliminate the usage of word "new" in the ...
1
vote
1answer
43 views

Automated test for code that takes a bunch of input data and outputs a bunch of data - should it be split up?

I'm about to write a program and test(s) for it. This question is about how to structure the top-most level integration test. At the top level, the main program takes a chunk of data, and outputs ...
3
votes
0answers
86 views

How to think about a schedule that pulls from a database as objects

I am working on a personal project using Python. I have been using version control to the best of my abilities and if you would like to check it out and run the app https://github.com/CodeAmend/old-...
5
votes
7answers
416 views

Is it appropriate to not follow the O/C principle if you have unit test coverage?

I find it more convenient to 'modify'existing classes rather than extending them. Thus, I violate the open closed principle of 'not modifying the compiled and tested source code, instead extending the ...
21
votes
4answers
2k views

How can CI be used for interpreted languages?

I have never used a Continuous Integration system (CI) before. I primarily code in MATLAB, Python or PHP. Neither of these have a build step and I do not see how a CI could be used for my work. A ...
3
votes
2answers
109 views

Verbosity of unit testing in untyped languages

I'm asking myself how verbose I should be when unit testing projects written in untyped languages like Javascript. Let's take an example for a strongly typed language (C#) public bool Foo(MyClass ...
7
votes
1answer
199 views

How should the code for a program outputting to command line be tested/designed?

Imagine a program similar to this in Python: import subprocess class Example(): _cmd_args = (['ls', '-a', '/usr/bin/'], ['ls', '-al', '/usr/local/bin/']) _default_args = 0 def init(...
0
votes
0answers
117 views

What to unit-test when loading a dll?

I wrote a wrapper class that is using a dll. I have a LoadLibrary() function and have wrapped all the functions the dll exports (to match my error codes). I am not too familiar with unit testing. I ...
7
votes
2answers
167 views

Is there any value in asserting values prior to acting in unit tests?

Here's a silly psuedo-object to illustrate the point: public class Testing { public object MyUnderlyingObject = new object { Property = 44 }; public MyPropertyWrapper { get ...
5
votes
2answers
229 views

Respectable design pattern for making node modules flexible/testable?

I am looking to get some input from some more experienced testers than what I am. :) I am trying to make my node modules testable, allowing for dependency spying/stubbing/mocking without the need to ...
3
votes
3answers
248 views

Unit Testing and 3rd party packages. Do I mock or not?

I'm just getting used to unit testing and on my new project I decided to adopt a TDD approach. My code below is to test the UserServices class which is responsible for creating a user, deleting a ...
0
votes
0answers
55 views

Where do you put your profiling code?

I just developed an algorithm and additional to the usual unit tests I wrote a profiling "test" that I was using to measure and optimize its performance. It is structured similar to a test (arrange: ...
0
votes
0answers
79 views

Running unit tests for an Azure solution built by TeamCity

We have a solution containing a Web Role and Worker Role. This is built by TeamCity and deployed by Octopus Deploy to a Microsoft Azure environment. The solution contains unit test assemblies (MSTest) ...
0
votes
2answers
217 views

Should a Junior programmer add TDD tests to mvc project

I'm a junior programmer near to my 6 month probation, following my initial career changing 3 month assignment in which I added TDD tests and wondering whether I should add tests to my current work. ...
-2
votes
3answers
184 views

What is the most elemental workflow for TDD?

Gradle is such an interesting build tool that it prompted me to look at Spock and JUnit -- which I've never done before. What is the basic workflow with TDD? My approach has been to do frequent ...
4
votes
3answers
112 views

Unit Testing Module-Internal Functions

I'm writing a simple whitebox unit testing suite for a project I'm working on in C. The project is broken into modules (each has a .c file with an associated .h file), and all modules are compiled ...
4
votes
1answer
92 views

When does it make sense to include test code in coverage?

Many coverage tools evaluate an entire project, including unit test code itself. In VS 2013, the Analyze Code Coverage/All Tests option includes test code in its report. OpenCover does so as well I ...
2
votes
2answers
188 views

What is it called when you test a microservice by mocking the dependencies?

I've a RESTFul microservice written in Grails. This microservice has it's own DB. It also depends on two other microservices. A typical workflow of the service is: Receives a GET request from a ...
4
votes
1answer
202 views

Writing a valid test case for validating XMLs

How would I write a unit test, say JUnit, for validating an XML file? I have an application that creates a document as an XML file. In order to validate this XML structure, do I need to create an XML ...
4
votes
2answers
101 views

How do you evaluate automated testing for a particular product/project?

Automated testing is pretty hyped-up in recent years, with particular emphasis on TDD at the "unit" level. The touted advantages include things like: Stabilizing existing code: breaking changes are ...
2
votes
1answer
88 views

How far do I, or can I take TDD tests with Service Objects?

In writing PHPSPEC tests for a Zend Framework 2 application, I'm left wondering how far to 'dig'. Consider this very simple case: A DomainService (Domain in the URL sense of the word) should be ...
82
votes
9answers
9k views

What's the point of running unit tests on a CI server?

Why would you run unit tests on a CI server? Surely, by the time something gets committed to master, a developer has already run all the unit tests before and fixed any errors that might've occurred ...
2
votes
1answer
161 views

Unit test express controllers?

I'm using meanjs for a project. It includes a yeoman generator with some express tests (model.test.js & routes.test.js) The tests do exactly what they advertise. My question is though, should I ...
3
votes
2answers
359 views

Differences between Given When Then (GWT) and Arrange Act Assert (AAA)?

In TDD there is Arrange Act Assert (AAA) syntax: [Test] public void Test_ReturnItemForRefund_ReturnsStockOfBlackSweatersAsTwo_WhenOneInStockAndOneIsReturned() { //Arrange ShopStock shopStock =...
0
votes
3answers
128 views

At what point in a projects life-cycle do you begin writing tests? [duplicate]

I'm not in the field, so I don't have any professional experience from projects following the TDD design. I am trying to adopt this pattern, but I'm confused as to when I start actually writing the ...
1
vote
1answer
200 views

How can you easily unit test deserialization to different versions of an object?

I am using the protobuf-net library for serialization/deserialization of messages. Due to the distributed nature of the application some applications will have an older version of the object that is ...
7
votes
1answer
122 views

Unit Testing: Assembler code and different architectures

I am currently unit testing some C code and I am faced with a problem: Within the code there are called functions that contain inline assembler code for the SPARC 8 architecture. Since I am doing ...
6
votes
2answers
343 views

How does breaking up a big method into smaller methods improve unit testability when the methods are all private?

I'm presently reading Building Maintainable Software by Joost Visser and some of the maintenance guidelines they recommend include: A) each unit/method should be short (less than 15 lines per method) ...
3
votes
3answers
142 views

How do you test a selenium framework?

I have a very large selenium test framework I use to test a web application. It it built around a page-object pattern. This week I fixed a bug in a low level piece of the framework, but it broke many ...
1
vote
2answers
129 views

how to unit test constant that define an implementation detail?

How do I unit test a constant that define an implementation detail? and should I? For instance let's say I have the following class: class A { private Cache _cache; const int ...
3
votes
2answers
185 views

How unit test service method that use repository method

For service methods that call repository methods to interact with database how could I unit test these service methods? For example, public function updateSlideshow($data){ // do some logic ...
8
votes
3answers
391 views

Anonymous namespaces make code untestable

Here is a typical C++ code: foo.hpp #pragma once class Foo { public: void f(); void g(); ... }; foo.cpp #include "foo.hpp" namespace { const int kUpperX = 111; const int ...
5
votes
2answers
960 views

Should I write automated unit tests that fail when the code changes?

Generally when writing automated unit tests (eg JUnit, Karma) I aim to: cover all the boundary conditions get a high level of coverage. I heard someone say: coverage and boundary conditions ...
13
votes
5answers
527 views

Broken Old/Legacy Unit Tests

I work for a big company and I'm responsible for a large java application with thousands of junit tests. Since I moved to this role, there have been 200-300 broken tests (likely broken for years). ...
2
votes
2answers
139 views

Having a TestContext to test methods instead of Dependency Injection

I am working on a legacy code base and I need to find a way to write unit tests for this project. The project has a three layer architecture (UI-Biz-DAL as we call them) and DAL is totally ...
1
vote
2answers
154 views

Testing using mocking, must I mock all dependencies too?

I have the following method to test: public List<MarkId> getMarkIdList(ICar carDoc) { ICourseCar courseCarDoc = courseCarRep.get(carDoc); List<MarkWag> markWagList = ...
4
votes
3answers
171 views

How narrow should my unit tests be?

Here's an example: I have a chat module in my app, and there's a ChatService class that is responsible for networking, and there's a ChatNotificationService helper class that is responsible for ...
6
votes
1answer
499 views

Unit testing an API client and wrappers

I've been going round in circles trying to figure out the best way to unit test an API client library I'm developing. The library has a Client class which basically has a 1:1 mapping with the API, and ...
3
votes
1answer
122 views

How to move Python doctest examples into another unit test framework?

Years ago AFAIK the mathematitician and software developer Tim Peters discovered that very often the documentation of APIs tends to get out of date over time during the software live cycle, because ...
9
votes
1answer
165 views

Unit testing for data munging pipelines made up of one-line functions

Reading Mary Rose Cook's Practical Introduction to Functional Programming, she give as an example of an anti-pattern def format_bands(bands): for band in bands: band['country'] = 'Canada' ...
0
votes
1answer
72 views

Reusing array with static test data across test classes

I have a Map which takes in an a String key, and an array of custom objects as the value. the map usually contains two entries, and the arrays for both entries never change in terms of data; once they ...
32
votes
9answers
2k views

Is it reasonable to not write unit tests because they tend to get commented out later or because integration tests are more valuable?

I was discussing unit/integration testing with a colleague, and he made an interesting case against writing unit tests. I'm a big unit test (JUnit primarily) proponent, but am interested to hear ...