Unit testing is a method by which individual units of source code are tested to determine if they are fit for use.
1
vote
0answers
22 views
One class unit-tests
Its my first attempt to unit-test in Js. Not yet TDD.
What I can change?
EventsPersistancyService.js:
...
3
votes
2answers
46 views
Finding duplicates in given list of files
I implemented a simple tool to find duplicate files, by applying the following strategy:
Take a list of files and return the sets of duplicates (set of sets)
Implement a custom ...
6
votes
2answers
37 views
Unit testing F# code without using an existing test library (MSTest, xUnit, etc.)
I know I can probably use MSTest (I'm under Linux without an IDE so maybe not?) or another unit testing library, but for a small project I decided to write my own unit tests without resorting to a ...
4
votes
1answer
81 views
Testing an abstract class
I started writing a set of tests for my SageContextBase class, which needs to be abstract because the client code must derive ...
0
votes
1answer
114 views
CRAP index (56) in Web Scraper Engine
I am working on a Web Scraper for the first time using Test Driven Development, however I have caught myself into a huge CRAP (Change Risk Anti-Patterns) index (56) and I can not seem to find a ...
2
votes
1answer
46 views
Sampling with weighted probabilities
In an exam question I need to output some numbers self.random_nums with a certain probability self.probabilities:
I have ...
2
votes
1answer
23 views
Testing a socket-based application
Summary: How can I best write tests that override socket-based communication for a library, capturing what is sent over the socket, and simulating responses based on what is sent?
Details
I'm adding ...
5
votes
2answers
55 views
Recursive binary search implementation in Python
I have this (recursive) binary search implementation in Python, and I want you to criticize every aspect of it. It is a naive implementation, (drilling the basics and stuff), but, I want you to ...
0
votes
0answers
19 views
Validate if time is valid including tests
So, I'm working on a method to validate if given time(s) are valid. In most cases, the input comes from the user. I'm not exactly sure on a few points:
Readability
Integrity
Performance
I'm also ...
5
votes
1answer
67 views
8
votes
2answers
118 views
Next number with the same sum of digits
I recently came across a email bot that would give you random problems to solve.
Here is the problem.
Please write a function in python which receives a natural decimal N-digit number (1 to 15 ...
4
votes
1answer
41 views
String concatenation comparisons
For some time, JavaScript string concatenation could be optimised by join()ing an array of strings, instead of +ing them ...
4
votes
1answer
55 views
Simple Ruby program to model a prepaid transit card system
I have written a simple Ruby program to model a transit card system which aims to address the following user stories. I wanted to see whether I could get any feedback on it. My main interest is ...
6
votes
4answers
128 views
Unit Testing the Duck
I recently reinstated the unit tests in Rubberduck. Previously, our parser was a synchronous parser, with everything running in sequence, and we could just request a parse result. Now, however, it ...
6
votes
1answer
124 views
Creates a menu and sidebar in Google Spreadsheets
In an effort to make my code more testable, I'm trying to make use of constructors and prototypes.
Here is a working Google Apps Script (GAS) for creating a new submenu under the Addon main menu in a ...
8
votes
2answers
111 views
Number to Roman numerals
I've been working on numerals conversion lately. Now the JavaScript course I'm following asked me to do something similar for Roman numerals.
To keep things fresh and given the amount of test-cases ...
7
votes
2answers
592 views
Simple DateTime abstraction
Some of my tests require that I need to test the date time results (like time stamps etc.). In order to be able to test the date time string I created a simple ...
2
votes
2answers
99 views
Check if a word is before another
Let's consider a method like this:
public bool IsWordABeforeWordB(string Text, string WordA, string WordB)
{
...
}
By Word ...
2
votes
0answers
97 views
ASP.NET MVC with automatic testing (follow up)
This is a follow-up of this question regarding MVC application architecture fit for automatic testing.
I have rewritten the DI code based on the answer provided there and also created some tests to ...
4
votes
1answer
47 views
This function for populating the attributes of a class, using a DB model and REST API
Recently, I've been trying to transform my code to be more OO and adhere to SOLID principles. I also have been trying to get into the habit of making my code more testable and have been trying to ...
3
votes
1answer
78 views
Unit testing with dependency injection and MOQ
I'm just learning how dependency injection and mocking work, but I'd like some feedback on how I'm setting up a couple of tests. I can get them to pass, but I'm not sure this is all I need.
This is ...
3
votes
0answers
34 views
CIDR Notation parser
I created the following code to better understand CIDR notation. Also to learn some of the Stream features in Java8. I posted my unit tests too.
I'm interested in ways it might be improved ...
1
vote
1answer
106 views
ASP.NET MVC application architecture fit for Unit Testing with Mocking
I am trying to learn how to professionally work with Unit Testing, so I have refactored a medium sized project of mine (a sort of article aggregator that also does some ...
14
votes
2answers
243 views
All your bases are belong to Dijkstra
CATS, willing to get a hold of all the bases, asked Dijkstra to give him a hand designing the most powerful algorithm to reach all bases with the least distance travelled.
I tried to implement ...
5
votes
1answer
147 views
Geocoding hook for a TYPO3 extension
I'm currently developing a TYPO3 Extension in PHP and developed a Hook.
TYPO3 has the concept of Hooks where you can execute your own code as specific points. As defined in our definition of done, we ...
5
votes
4answers
137 views
Writing to a newly created file, with support for unit testing
When now increasingly making code unit testable, I notice that code gets bloated, only to get dependencies out. A simple file operation, like saving a file, and, if a file with the name already ...
3
votes
1answer
71 views
Unit Testing Express Middleware That Verifies Auth Tokens
I am writing an Express middleware component that'll run on Node 4, which has limited ES2015 support.
The fundamental purpose of this component is to verify JSON web tokens, using the jsonwebtoken ...
2
votes
1answer
27 views
Converting fraction notation in strings to a Rational data type
I've been messing around with a RationalInt type, using a simple
int-based structure for the time being. I've created code to ...
9
votes
1answer
97 views
Tokenize s-expressions in Rust
I'm writing an s-expression tokenizer in Rust.
I have the following code written, but it is not idiomatic Rust - it is quite ugly. TokenizerI is simply an ...
11
votes
4answers
731 views
Using reflection in a test to check if a private variable is really null after a function, is this okay?
I am using reflection to check if a private variable is set to null after the logout function. This is needed because the getUser function will always attempt to set and return an user if no user is ...
3
votes
1answer
48 views
Test cases for an elevator simulator
I'm trying to test an elevator simulator program that runs in the console and requires user interaction. At the moment, my tests look like this:
...
0
votes
1answer
86 views
Angular directive test
I'm learning how to write tests in Angular (these are my first tests in general). There are a lot of tutorials out there but each one of them has a different approach. I'm a bit confused if I'm doing ...
2
votes
2answers
62 views
Sales Tax problem (new version)
I was told that this version is too simple, that need something more complex. I added Entity Framework.
Here my code:
...
1
vote
0answers
65 views
Integration tests for a repository with the help of AutoFixture
I find it hard to do integration tests for a repository and very time consuming.
Things I think about when creating integration tests for a repository:
Should I skip them?
Should I create an in ...
14
votes
2answers
130 views
Builder pattern for users in document database
I'm attempting to make a builder pattern that makes sense and is practical for storing user data in a flexible way in a document database. The DB I chose is MongoDB, and I'm using its Java API ...
8
votes
4answers
347 views
Implementing common fraction using TDD
Recently, during the interview, I was asked to implement basic arithmetic operations with common fractions using TDD. The task is fairly simple, but I was nervous so I did not do too well. :) Later on ...
1
vote
0answers
116 views
REST service API using Python Bottle
I am working on a sample REST service to study testing related aspects using the Python Bottle framework. I read a lot about REST but I do not have a lot of practical experience designing RESTful APIs ...
6
votes
2answers
121 views
String Calculator Kata in Scala
This is my solution of string calulator kata in scala(i'm new of tdd).
I'd like a general review of this.
String Calculator
Create a simple String calculator with a method int Add(string
...
1
vote
1answer
537 views
Entity Framework 7 In Memory Database - Unit Testing using xUnit
I'm using EF7 with In-Memory database and xUnit for repository testing. I'd like to know if it's a good practice initializing the database in this manner for reuse it in every test method, ...
5
votes
2answers
81 views
Unit test for a function that adds users
I'm new to unit testing and I'm curious if anyone can see any problems with my approach below. Basically I want to test the Add function. To do this I am creating ...
5
votes
2answers
187 views
Checking if text is NOT displayed
I'm currently writing unit tests in Selenium (C#). I need to do two things in this particular test:
Check if 2 errors (with html container) are displayed and check if another (given) error is not ...
5
votes
1answer
52 views
Test whether target string is substring of source string
The code is self-explanatory. It has \$O(n)\$ complexity, and it tells whether a given string is the substring of the source string. Are there any cases where this algorithm fails? Is there anything ...
2
votes
3answers
254 views
Solving for equilibrium index in an array
I did a sample on Codility and finished the test task.
The problem description is very short:
The equilibrium index of a sequence is an index such that the sum of elements at lower indexes is ...
7
votes
3answers
354 views
Implementing xrange
I wanted to learn about Iterable and Iterators and hence thought about getting my hands dirty rather than reading theory and ...
2
votes
0answers
56 views
Are AVL trees equal? - revision 3
The original question
Given two binary trees, return true if they are structurally
identical, and false otherwise.
Are AVL trees equal?
Are AVL trees equal? - revision 2
This revision on ...
5
votes
3answers
134 views
ASP MVC Controller Unit Test
So I've been writing a unit test using Rhino Mocks to a controller in my ASP MVC application. The test passes, but I'm interested in your opinion and if there's something I should be doing differently ...
6
votes
0answers
40 views
Generate a URL, shorten it, insert it in a tex file and compile those tex files
I have written a NodeJS module and its tests to generate a URL, shorten it with Bitly, insert the short link in a tex file, compile these tex files to PDF and then merge them into one.
The code is ...
1
vote
1answer
60 views
Are AVL trees equal? - revision 2
Revision 1.
This revision on GitHub
In addition to the solution itself, I wrote tests for all the possible
cases.
It seems you have verified all execution paths are covered.
You are ...
4
votes
1answer
58 views
Hacky Haskell monadic testing
Edit for posterity: The library you're looking for is Hspec.
I recently started writing Haskell tests with HUnit.
My general setup looks something like this:
...
3
votes
1answer
1k views
EF Generic Repository + Unit of Work pattern with support for Async
I'm working on a generic repository using EF 6 code first and trying to following the Unit of Work pattern. Unity is being used to inject my repositories, and I'm trying to get everything supporting ...