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

8
votes
2answers
39 views

Testing classes

I'm just getting into testing and wanted to see if someone can tell me if I'm writing tests correctly. I'm using C#, NUnit, & Should. This is the class I'm testing: using System; using ...
6
votes
1answer
81 views

Unit test best-practices in Python

I'm a Java/C coder getting started with some Python for a side-project. I've written some unit tests for a recent side-project I'm working on, but I have a sinking suspicion I'm just writing ...
3
votes
1answer
34 views

Python Fizz Buzz, Acceptance Unit test

OK, maybe crazy overkill and a little silly, but why not? Here's a Python FizzBuzz Acceptance Test: import unittest from fizzbuzzmodule import fizzbuzz class ...
5
votes
1answer
83 views

Does this FizzBuzz code correctly follow SRP and unit-testing?

This is a code for FizzBuzz. I have also hosted in on my github FizzChecker Tests [TestClass] public class FizzChecker_Tests { IFizzChecker _fizzChecker; bool isFizz; [TestInitialize] ...
1
vote
3answers
66 views

How to (really) unit test an adapter?

My question is really simple: shall an adapter (design pattern) class be unit tested, and how? Example: I want to create a class ClientSocket with PHP, which is an adapter of the fsockopen, fread, ...
4
votes
2answers
71 views

Is the public interface easy to use and the documentation understandable? Are the unit tests well-written?

I have a year or so of experience in developing in Java. I submitted the solution for this task, but never got the feedback that was promised. Since I still would like to get a feedback on my ...
4
votes
3answers
79 views

Extracting pattern and simplifying testing

I observe the same pattern in a number of my classes but can't extract/abstract it due the tight coupling inside each particular implementation. Having the class accepting an optional number of ...
4
votes
2answers
44 views

Review of java interface for constructing brain model

I have built a partial human brain model and the following is an example of how I use all the classes. I was wondering if anyone could critique my implementation strategies because I feel like the ...
2
votes
0answers
75 views

How to improve this code for testability?

I'm trying to improve the following code for testability. public function can_apply_extension() { $search_dates = [ ...
2
votes
1answer
42 views

What is a better way of organizing a Python project? [closed]

I have some questions to ask on how to better organize a Python project: Where to put your unit tests scripts? Where to put your init script? How to show your module version? Here is my project ...
1
vote
1answer
93 views

Is this good practice with unit-testing?

I've created unit test for the "student" CRUD operations that looks like this: [Test] public void Can_Exec_CrudOps() { #region Prepare var account = Processor.Execute(new ...
1
vote
0answers
159 views

Modelview programming in PyQt4

In my first attempt, I have tried to load images from disk and load it to a QTableView using QAbstractTableModel. I'd like a general code review of this code. import sys import os from PyQt4 import ...
1
vote
1answer
63 views

Feedback on logic implementation and testing

This is my forked branch attempting to make the code better, This is an application for having a slide show of photographs in current directory or supplied as argument. Use keyboard controls[left to ...
1
vote
0answers
42 views

Symfony2: Extract method from controller, form events, remove conditional

I have a fairly ugly controller method I would like to refactor / extract. I can only test this in a integration type test which kind of signals a code smell. The method processes the form and needs ...
1
vote
1answer
59 views

Remove duplication in python code for dict schema validation

I want you to look the following code for validating dictionary schemas. There are some libraries out there that do the same thing, but I just wanted to write my own for fun and not to overload my ...
4
votes
1answer
107 views

First ever unit test. Am I headed in the right direction?

I'm learning backbone.js in parallel with unit testing. I've just made a simple model and wanted to unit test it. Do I have the right idea? I am simply making a model with some default values. ...
3
votes
2answers
111 views

Test if two IDictionary objects contain the same values

I'm adding a function to my test library to assist in testing if two IDictionary objects contain the same keys/values. I need the method to be generic and support a dictionary that has collections as ...
0
votes
2answers
83 views

Improve testability of constructor

I have the following constructor /** * @param codePath path to player's code. If ends in '/' it assumes the code is in .class'es in * a directory; otherwise assumes a jar * @throws ...
1
vote
3answers
263 views

Make WCF Service testable

I have WCF Service. Its work fine and I want to have test coverage for it. Unit tests and acceptance. The problem is static class using in the code. How is it possible to avoid it? If it will ...
1
vote
1answer
33 views

Proper way of a testable method with multiple return points [closed]

I have the following piece of java method code: @Override public void applyStates(int timestamp, State[] states) { // Calculate the time diff between current time and the time stamp of the given ...
1
vote
2answers
66 views

Checking name E-mail and unit-test

Please tell me what you think. Is my code bad? Function checking #-*- coding: utf-8 -*- import re import unittest def email_check(mail): # E-mail as argument func compil = re.compile(r""" ...
2
votes
1answer
119 views

Method names for encapsulated unit testing logic. Which convention is better?

I have some C# unit tests which each basically perform the same steps but supply different arguments to the unit under test. I wanted to encapsulate the logic inside some "helper methods" but found ...
2
votes
2answers
87 views

Testing an Executor

I have written the following Executor: /** * <p>This executor guarantees that there is never more than one element waiting to be executed. If an element is * submitted for execution and ...
1
vote
3answers
50 views

Is my code unit testable

I've written a piece of code. Would like to know is the below piece of code unit testable or does it need any kind of refactoring. MatchCilentUrls is the primary method for matching two urls. Based ...
1
vote
1answer
30 views

Throwing error if settings / arguments are undefined is this a good breakout function?

var _ = require("underscore"); var checkSettingsUndefined = function(settings){ if(_.isEmpty(settings)){ throw new Error("settings are empty"); } } var Class = function(settings){ ...
1
vote
1answer
151 views

Code review on an API wrapper in C# wanted

I'm looking for remarks on pretty much anything. This has been my first project that's meant for use by others and I'd like to have it as clean as possible. I will post the main source code here but ...
0
votes
0answers
47 views

Zend Framework and Doctrine 2 - are my unit tests sufficient?

I'm quite new to Zend and unit testing in general. I have come up with a small application that uses Zend Framework 2 and Doctrine. It has only one model and controller and I want to run some unit ...
1
vote
1answer
766 views

Advice on Zend Framework 2 and Doctrine

I've just started looking at Zend Framework 2 and Doctrine ORM, with a view to possibly using it in one of my future products. So far I have a very simple application which allows the user to select ...
3
votes
1answer
212 views

Unit test an ExecutorService in a deamon

To execute tasks sequentially with a timeout I use ExecutorService.submit() and Future.get(). As I don't want to block calling clients, I implement producer–consumer pattern with a queue into a Thread ...
1
vote
1answer
57 views

Can these collision unit tests be improved?

I'm finding it a bit tedious to write unit tests for my collision class because there are so many variations of collisions that need testing. I see repetition in the set-up and assertion stages of ...
0
votes
2answers
73 views

Using MOQ In Unit Testing

I am fairly new to writing unit tests, and I was wondering if this approach I have taken is on the right track? Given the following interfaces/classes: public interface ILoggingService { void ...
0
votes
0answers
39 views

Guice custom behavior for testing, how is this solution?

I have a Java/Swing/Guice application that uses multiple frames. When the application runs normally, I just want some of these frames to hide (and the "master" frame can unhide them). When testing ...
1
vote
0answers
112 views

Unit testing event triggering

I am writing a unit test for a Dispatcher that will route a HTTP request to a specific Controller and invoke a specific method on that Controller. It will also trigger various events at different ...
1
vote
2answers
125 views

Refactor code to make it more testable

I have this code that works fine. But I would like to create some unit test for this class. Most of the code is in private or void type methods. Please help me refactor my class to make it more ...
6
votes
1answer
164 views

32-bit counter and test bench

How could this VHDL counter and its test bench be improved? I am interested in anything you see that could be done better, but especially in the test bench: Is wait for 10 ns better or worse than ...
2
votes
0answers
318 views

Test mongoose model

I have mongoose model: var mongoose = require('mongoose'), Schema = mongoose.Schema, Imager = require('imager'), env = process.env.NODE_ENV || 'development', config = ...
0
votes
2answers
109 views

Is my JavaScript test actually testing anything worthwhile here

Given a production module like this: function ($) { var showForm = function () { $.get(url, function (html) { $('body').append(html); }); }; ...
6
votes
1answer
306 views

Is this the proper way of doing timing analysis of many test cases in Python or not

Chat room for discussing this question. I am learning about timing analysis in Python. I used time module before it was pointed out that timeit module would be better for timing analysis. My main ...
0
votes
0answers
194 views

Is this factory method a good approach?

We are beginning to learn Node.js and we are not always sure if we do it the right way. We have a strong object oriented background so the adoption is not always easy. Right now we implemented a ...
2
votes
1answer
172 views

Help with comparison counters in quick sort algorithm

At the suggestion of @templatetypedef, I am posting the code for my quick sort to see if anyone can offer suggestions as to where to make comparisons. And any tips on improving the code. I am using ...
1
vote
2answers
64 views

Unit Test to verify number of times lazy initialization logic is executed for a data member

I'll write a small simulation of my actual class first to request insights on unit testing one of the behaviors of this class. Here is my class A: public class A { private final String a; ...
2
votes
1answer
181 views

Is a unit test which uses LINQ to check multiple values acceptable?

I'm writing unit tests for a library which parses colors from user input (example: the user input “#f00” gives a red color; the user input “60,100%,100%” gives a yellow color, etc.) One of the ...
2
votes
2answers
68 views

Two dimensional unit testing

Consider a process composed of three algorithms: makeRuns, meld and traverse (each taking the output of the previous one as input): it is interesting to test each separately. Now consider three (or ...
2
votes
1answer
34 views

Generic test serie for various solutions to the same algorithmic problem

I am learning how to use the module unittest for test-driven development. Below is a simple yet practical example of an issue I will have many times: one single problem (e.g. an Abstract Data Type ...
2
votes
1answer
138 views

Unit test provider roles

I am unit testing this role provider. I have a few asserts in the code for my test. I am sure there are more test I could preform. Does anyone have any suggestions for more test for this role of the ...
3
votes
2answers
152 views

How can I optimize this code for unit testing

How can i optimize this code with less number of loops and return values for unit testing public class Diamond { public void DiamondShape(int num) { for(int ucount=num;ucount>0;ucount--) { ...
1
vote
2answers
203 views

Am i fake testing or this is how mocking should be implemented?

I'm new to Rhino mock and i would like to know if the test i did is not fake testing as i red a lot about it. are there any improvements need to be done? [Test] public void ...
1
vote
1answer
80 views

unit-testing / mocking a class which contains functionality which depends on itself

Take the below code: public interface ISettingsManager { SettingData GetSettingByIdentifierOrCreateIfDoesNotExist(Enum identifier); T GetSetting<T>(Enum identifier); } [IocComponent] ...
5
votes
1answer
264 views

How do I make this code unit-testable?

I have a functionality that imports data into a database, based on an Excel workbook and some meta data (both user-supplied). The functionality implements interface IFunctionality which essentially ...
0
votes
3answers
338 views

I need help improving this design for easy unit testing

I am very new to unit testing, I only read a few chapters from 'Art of Unit Testing' and know how to write basic unit tests. I have a deadline for a project so I plan to read 'Professional Test Driven ...