Unit testing is a method by which individual units of source code are tested to determine if they are fit for use.
3
votes
0answers
62 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 ...
-1
votes
0answers
23 views
PHP: How to make testable static methods [on hold]
I decided to make my own poor man's ORM framework. Since I did not know how to go about it I decide to develop before testing. Github. After making it work the way I want, I realise that my code was ...
5
votes
4answers
81 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 ...
1
vote
1answer
31 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
22 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
52 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
707 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
37 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
54 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
58 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
39 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 ...
13
votes
2answers
114 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
329 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
48 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
106 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
158 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
77 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 ...
3
votes
2answers
83 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
45 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
129 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
334 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
43 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
124 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 ...
4
votes
0answers
25 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
49 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
50 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
649 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 ...
2
votes
2answers
53 views
C++ Minimalistic Unit Testing Library
I was looking for a unit testing library for C++, and I found many. Unfortunately, I decided I didn't want to use any of them. I decided to make my own.
This is the result. I made heavy use of the ...
5
votes
1answer
88 views
An attempt on unit testing in C++
I have no much experience with C++, so it is about time to start actually doing something about it. All in all, I coded this tiny unit test library:
assert.h:
...
4
votes
1answer
55 views
Unit Testing and good use of matchers
I been having discussion with colleagues recently about good use of matchers. Consider the following sample:
...
10
votes
1answer
107 views
Find all the primes less or equal than N
This is not a novel interview problem. But I want to address it with the following points:
Implement the algorithm with Object-Oriented Design principles in mind.
Optimize the solution, if there are ...
3
votes
1answer
72 views
Bot that selects web reviews based on spreadsheet entries
In my program, I prompt the user to enter a range of cities (in a spreadsheet), and then a range of review scores, and then make some decisions based on what the user has entered. Since the handling ...
0
votes
1answer
50 views
Basic sign-up method, testable and with try/catch [closed]
I am learning how to implement testing and try/catch statements into my code. I have a Laravel application with the following ...
7
votes
1answer
197 views
Are AVL trees equal?
I was inspired by this answer and decided to implement an AVL tree with the methods equals and hashCode as if I was asked to do ...
4
votes
1answer
84 views
Swap items of a linked list in pairs - revision 5
Here is the source of the question.
Given a singly linked list, swap the list items in pairs (reconnect
the pointers, not simply swap the values). For example:
Before: A->B->C->D
...
5
votes
2answers
384 views
Mock/Stub out filesystem in F# for unit testing
I'm looking to do some basic verification testing on my functions that write to the filesystem.
I took a hint from here on how to mock out the filesystem using an interface, but I'm kinda bummed on ...
2
votes
0answers
74 views
Mocking the file system within a test
I've been using this method to test file-system functions as an alternative to mock-fs due to its lack of symlink support. I'd love to hear what others think and ...
4
votes
1answer
103 views
UTF-8 encoding/decoding
I have two functions, a collection of possible error codes, and a unit-testing framework.
The parsing of a character into its unary prefix and payload is handled by a few named functions and macros ...
1
vote
1answer
63 views
Swap items of a linked list in pairs - revision 4
Here is the source of the question.
The solution on GitHub.
Revision 1.
Revision 2.
Revision 3.
@200_success' suggestions from revision 3:
The iterator's ...
4
votes
3answers
120 views
Unit tests for a simple composite
I do a lot of unit testing(tdd) and would like some comments about my style. Here is a simple example from a composite.
Is there anything I could improve?
...
3
votes
1answer
62 views
Unit testing a service to return items from a database
I have been a developer for many years and get core development concepts, as well as unit testing ones such as DI/Ioc, Mocking etc. I also understand the values, importance of unit testing and writing ...
2
votes
1answer
36 views
Swap items of a linked list in pairs - revision 3
Here is the source of the question.
Revision 1.
Revision 2.
When I started the second round of code review, I wanted to make sure that I had included all the possible input types. However, I ...
3
votes
1answer
88 views
Unit-testing an RSS feed parser
I'm working on a class to parse RSS feeds using SyndicationFeed. (related to Downloading data using HttpClient). I'm trying to write this so it can be unit-tested, ...
3
votes
1answer
86 views
Swap items of a linked list in pairs - revision 2
The first revision is available here and the code is available on GitHub. I modified the method reversePairs and added mSize to ...
4
votes
1answer
165 views
White box input stream for creating test scenarios
I need to test a specialized input stream class that takes input from a TCP/IP network connection. I particularly need to ensure that the blocking and availability behavior is correct.
To help me ...
5
votes
1answer
254 views
Testing boto connection
I am writing a unit test to be sure the code can connect to aws via boto, since I will be putting the credentials in place via some other process than code deployment. So far, I've only figured out ...
11
votes
2answers
126 views
Unit testing with a singly linked list
To hone my skills with C++11, I'm implementing a singly-linked list based on the requirements I found at this link.
I've implemented code that supports the following subset of requirements from the ...
6
votes
1answer
86 views
Monoalphatic and Polialphabetic cipher in Ruby
This code encrypts a text with mono-alphabetic and poli-alphabetic substitutions ciphers.
For further info see:
Mono-alphabetic/Caesar Cipher
Poli-alphabetic cipher
...
16
votes
2answers
4k views
Go on, mock my IDE
Because of the coupling with the VBIDE API (the extensibility library for the VBA IDE), unit testing the rubberduck refactorings, inspections and quick-fixes has been pretty much impossible, at least ...
10
votes
1answer
327 views
Robot toy simulator
I have already flunked the test with this code so don't feel bad for cheating any employer. I didn't get any feedback though just wondering what could have gone wrong.
You don't need to get into the ...