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

11
votes
3answers
135 views

Trading Card Game's Hand class and tests

As part of a Trading Card Game, I have created a Hand that will need to hold all cards that a player currently has in his hand. The code is built using Java 8. The ...
9
votes
1answer
93 views

Automatically run doctest every time program is run

I would like this to happen every time I run a program from the command line. Is my approach Pythonic? I'm interested to know whether there is any problem with readability or correctness. Any general ...
3
votes
1answer
74 views

Unnecessary unit test?

I have this method in my service layer ...
6
votes
3answers
106 views

Unit tests: to cast or not to cast?

Suppose the following example unit test for an ASP.NET MVC controller: ...
4
votes
2answers
56 views

Server side validations and unit testing in MVP

We are following passive controller approach and when user clicks on submit, server side validations are fired. There are many other fields on the screen that needs to be validated. I would like to ...
3
votes
1answer
40 views

Testing async API calls using Jasmine 2.0

I'm upgrading my project from YouTube's V2 API to their V3 API. I'm also taking the time to upgrade to Jasmine 2.0 since I already need to look at my test cases. Here's a couple of test cases and the ...
10
votes
4answers
297 views

Schedule class (exercise for test driven development)

Schedule is a simple class that could be used in program to manage when a task should be repeated (a todo list, for example). Its constructor requires a start date and an optional end date. Then type ...
4
votes
1answer
33 views

Ranking a variant array with variable dimensions

I'm doing VBA macros and need to use Arrays of values extensively. After the below help from @TonyDallimore in StackOverflow, I've decided to use nested variant arrays. VBA chrashes when trying to ...
7
votes
3answers
132 views

Refactoring method to make it unit testing friendly

I have a completed application which I'm trying to write unit tests for (Yeah I know, talk about bad practices) I have the following class here ...
4
votes
1answer
102 views

Am I over-engineering?

So I just jumped to a new project, which uses activerecord pattern. It's a subscription service website. I have the following User object that extends a framework specific ORM object. ...
11
votes
3answers
1k views

Sudoku Solver: what are good ways to avoid the deepcopy?

In an effort to teach myself some python and programming in general I made a Sudoku Solver (as many others have done before me from what I can tell). The one thing that bugs me a little is my use of ...
0
votes
2answers
57 views

Unit Testing Datalayer written in ADO.net

I have datalayer code as below which is implementing an interface as: Note: I have hand written this code on Notepad so it may contain some typo errors, which you can gracefully ignore. I am ...
9
votes
2answers
193 views

Using a Pythonesque range() generator function with the Java foreach loop

Now that we have the nice new foreach loop in Java, the old-style loop looks ugly be comparison. I like the way Python has a range() generator that allows the ...
9
votes
1answer
110 views

Do my unit tests follow best practices?

I've watched quite a few videos and read a couple of articles on unit testing and I've tried my best to make this test case as good as possible. In which areas can it still be improved? I should ...
3
votes
1answer
92 views

Unit tests using C#, Moq, AutoFixture, FluentAssertions

Could you give any suggestion on the following unit tests? How to make it more readable, maintainable and trustworthy. If it is not a problem - post some code with the suggestions. ...
1
vote
1answer
80 views

Structuring unit tests

I have settled with this type of structuring of unit tests. Basic idea is that there is a base test class for the tested class, and a subclass for every tested method. They use the mocks and ...
4
votes
2answers
57 views

Implement strtod parsing

In this comment the OP wrote, I am a newbie so i would like to know how would i parse the negetive numbers/arguments ? In this answer @200_success showed an implementation using the strtod ...
1
vote
1answer
168 views

Unit testing - test class inheritance vs single test class [closed]

Which unit testing approach and WHY do you prefer? Inheritance-driven-testing ...
16
votes
4answers
1k views

Just a lowly counter that turned out to be surprisingly complicated

While writing this review, I saw a need for a Counter object similar to Python's. It seemed like it would be easy to write such a class, but it turned out to be ...
3
votes
2answers
102 views

My first model RSpec

This is my first model RSpec test: ...
6
votes
2answers
81 views

Create and destroy object in Unit Test

I have some doubt when I should create an object in an Unit Test when the object needs to be stopped cleanly. Usecase: I have a class ComplexClass which has 3 functions: Start(): starts a Thread ...
3
votes
2answers
65 views

Read Lines From IIS Log

The purpose of this class is to read an IIS log (or multiple ones). One thing to note is that the columns can differ based on settings in IIS. So a couple of concerns that I have: Is The ILogReader ...
3
votes
0answers
30 views

Doctest for a method that expects a filename parameter [closed]

This method gets a file_name string as an argument. What if I don't want to pass a file_name in the doctest? I just want to ...
6
votes
1answer
109 views

How should I structure my Unit tests for minimal Asserts?

I always see comments about how a Unit Test should only be testing one piece of functionality. For the most part, I definitely agree with that assessment. However, I'm working on testing a method ...
6
votes
3answers
725 views

Simple Hello World with unit tests

This is a simple hello world sample project used for instruction. I'm just looking for general comments on the approach and design. AdvancedHelloWorldTest.java ...
7
votes
4answers
375 views

Testing code with Debug.Assert

I have a small little function in a VB6 codebase: ...
2
votes
1answer
106 views

Where to put common method used in controllers that calls service layer?

I have an asp.net mvc5 web application using the repository pattern, and I have several controllers that need to call my _loggingService (queries audit logs) to get the last updated information for ...
7
votes
1answer
93 views

Are these the right type of unit tests to write?

Trying to get an understanding of proper unit testing, I've read up quite a bit and found myself writing tests like the ones that follow. Based on "best practices" etc., how am I doing as far as ...
7
votes
1answer
153 views

Measuring a method executing time

I have been playing around with some improvements to some sort algorithms like Selection Sort and Merge Sort and I ended up needing some sort of measurement to check if my versions were any faster ...
4
votes
1answer
106 views

PHP wrapper around an API - best practices

Here's a PHP wrapper around a public OAuth2 REST API. I would love to hear your thoughts and comments. Testing was a bit frustrating since I tried for my first time. Not sure if I have done the ...
1
vote
1answer
75 views

Is this a good approach to unit testing?

I'm relatively new to unit testing and having gone through quite a bit of pain I was starting to feel pretty good about my tests. The problem is, now I have a nice set of green ticks I'm also ...
1
vote
1answer
82 views

Testing mapping code

Obviously, you have to test mapping code somehow, even (or especially) if you use AutoMapper. Is there any way to make it less verbose? ...
2
votes
0answers
36 views

Are these CppUnit tests OK?

I wrote a CppUnit test suite to unit-test the code that I posted here which is a single routine that proposes how a Lua expression could be auto-completed. What do you think? I appreciate all the ...
2
votes
1answer
34 views

Multiple Services and Test Setup

Class To Test Some methods hidden for clarity ...
4
votes
1answer
104 views

Configuring Constructor Parameters and Unit Testing

Currently working on writing out some test for an iOS enterprise application. My concern is in this set up of my overloaded constructor. ...
7
votes
2answers
101 views

Am I missing any unit tests in this base class for testing equality?

I've created this abstract base class for testing the Equals method. The basic idea is that derived class implements methods to get: the primary test instance, ...
8
votes
2answers
92 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: ...
6
votes
1answer
396 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
73 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: ...
5
votes
1answer
115 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 ...
2
votes
4answers
108 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 ...
5
votes
2answers
95 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
112 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
74 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 ...
5
votes
1answer
127 views

Testable code with ORM factory

I'm trying to improve the following code for testability. ...
2
votes
1answer
156 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
110 views

Is this good practice with unit-testing?

I've created unit test for the "student" CRUD operations that looks like this: ...
3
votes
0answers
191 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 ...
1
vote
1answer
78 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 ...
2
votes
0answers
87 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 ...