Unit testing is a method by which individual units of source code are tested to determine if they are fit for use.
0
votes
0answers
9 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
83 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
1answer
61 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
69 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
112 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
32 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 ...
0
votes
2answers
57 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
96 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 ...
1
vote
2answers
66 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
44 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
24 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
0answers
84 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
40 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
348 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
111 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
52 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
63 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
33 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
90 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
105 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 ...
3
votes
1answer
97 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 ...
1
vote
0answers
168 views
My first tests: test mongoose model (node)
I have mongoose model:
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
Imager = require('imager'),
env = process.env.NODE_ENV || 'development',
config = ...
0
votes
2answers
107 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
295 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
132 views
Node.js: 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 ...
1
vote
2answers
57 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
157 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
64 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
32 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
119 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
145 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--) {
...
2
votes
0answers
48 views
Shaky on QUnit folder structure
I want to write something serious in JavaScript for the first time in my life. Knowing this, I want to do TDD and write unit tests. I have experience in JUnit, but yet, how to structure my project ...
1
vote
2answers
193 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
69 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
231 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
215 views
I need help improving this design for easy unit testing - C#
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 ...
1
vote
1answer
157 views
Verify collection as a method parameter
How can I verify that ohterClassMock.MethodToTest() was called with contracts?
That it was called with contract, that have Id = 1 and Param2 = 34 and also with contract2, which has Id = 2 and Param2 ...
4
votes
2answers
173 views
Do I unit test the correct thing
Thats my method to test:
public LessonplannerRequest GetWeeklyLessonplanner(int schoolyearId)
{
Schoolyear schoolyear = ...
4
votes
2answers
139 views
Recursive XML2JSON parser
I made a Python function that takes an XML file as a parameter and returns a JSON.
My goal is to convert some XML get from an old API to convert into Restful API.
This function works, but it is ...
2
votes
1answer
192 views
Testing database table creation with NUnit
I'm new to using NUnit and have written a test to check for the existence of a database table. I have the below code that should check whether a new table named NewTable has been created in the ...
5
votes
0answers
203 views
Doubts about the quality of an API designed for use with minimal effort
This is going to be long, and I do hope it is going to make some kind of sense; I apologize if it doesn't. I'll try to provide exactly the amount of context that is necessary to understand the ...
1
vote
1answer
111 views
Production code to be good for unit testing
I would like to advise if the following production code is good to be unit tested. The segment of the production code gets data from a backend service and displays it on the page. It is a class:
...
...
4
votes
1answer
195 views
How to make static methods testable?
I am creating an application which will be testable(unit + integration). In this application I have a FileHelper static class,
public static class FileHelper
{
public static void ...
5
votes
3answers
339 views
Maximum Sub-array Problem
I started taking a look at a programming challenge I had read about earlier today on 8thlight. Unfortunately, it seems to have been taken down and all I could remember about it was the problem posed: ...
1
vote
0answers
191 views
I implemented a User model with BackboneJS and RequireJS with test cases in Jasmine. How can I improve?
I've been taking a stab at implementing test cases using the Jasmine testing framework. To do so, I've made an application which has a User object. This User object is created by the server, but its ...
3
votes
3answers
110 views
Test Driving Interface Design
I have been doing TDD since I have started my first job out of university (about 5 months ago), most of which is working with legacy code. I started a personal project today and thought I would TDD ...
0
votes
1answer
97 views
how should you mock / unit test this method / class
I have the below code:
public interface IRepositoryService
{
/// <summary>
/// This will add conditions like Published = true, Deleted = false and PublisehdDate smaller than NOW
/// ...
0
votes
0answers
128 views
Testing WordPress with Mockery and a Facade
I've put together this gist with an idea about testing WordPress themes and plugins with Mockery and a WordPress facade object. I've love some feedback on the approach, please.
WordPressFacade
...
1
vote
0answers
102 views
Does this nodeunit test conform to best practices?
I have inherited a node-js project, and I am completely new to it. Fortunately, it is already covered by unit tests.
The class under test, FmsRescuers, has the responsibility of sending HTTP requests ...
1
vote
2answers
125 views
Is my code (clean code separation) is correct?
The code below is an approach of clean code separation, but I am confused if it is a right approach or wrong. Please suggest me.
public interface IRepository<T>
{
...