unit-testing

Where should I put Velocity template files for a command line utility built with Maven?

I have a small command line utility project that I'm using Maven to manage. The utility is a very simple app to populate a Velocity template and dump the results to a new file. My problem is where to put my Velocity templates. When I put them in src/test/resources/foo/bar/baz, mvn test fails because it can't find the referenced template,...

Unittesting IoC registration?

Should you unittest the code that registers components into your IoC container? If so, how? ...

Why does this simple Rails unit test fail when the actual is the same as the expected?

I have an extremely simple unit test. I'm not sure why it fails when the expected is the same as the actual! Here is the method I am testing: def calibration_constant big_decimal = self.coefficient * (10**self.exponent) return big_decimal.to_f end Note, that coefficient is "6.1" and exponent is "1" Here is the relevant test lin...

Can one access TestContext in an AssemblyCleanup method?

In Microsoft's UnitTesting namespace (Microsoft.VisualStudio.TestTools.UnitTesting) there are AssemblyInitialize and AssemblyCleanup attributes you can apply to static methods and they will be called before and after all tests respectively. [AssemblyInitialize] static public void AssemblyInitialize(TestContext testCtx) { // allocate...

Testing Frameworks for C

After doing some work with Ruby, Rails, and RSpec last summer and I learned to TATFT. Now I can't write code without writing tests first. I'm taking a programming course in C next year, and I would like to learn to write C test-driven. Is it a good idea (or even possible) to do TDD with C? If so, are there any good testing frameworks co...

Unit and Functional testing iPhone code?

I just sat in on a seminar about developing apps for the iPhone. The speaker told me that there is NOTHING available for writing unit tests or functional tests for your iPhone software. Is this true? Is there really no testing story for the iPhone as of now? ...

What are unit testing and integration testing, and what other types of testing should I know about?

I've seen other people mention several types of testing on Stack Overflow. The ones I can recall are unit testing and integration testing. Especially unit testing is mentioned a lot. What exactly is unit testing? What is integration testing? What other important testing techniques should I be aware of? Programming is not my professi...

How can I best write unit test cases for a Parser?

I am writing a parser which generates the 32 bit opcode for each command. For example, for the following statement: set lcl_var = 2 my parser generates the following opcodes: // load immdshort 2 (loads the value 2) 0x10000010 // strlocal lclvar (lcl_var is converted to an index to identify the var) 0x01000002 Please note that lcl_...

How do you (Unit) Test the database schema?

When there are a number of people working on a project, all of who could alter the database schema, what's the simplest way to unit test / test / verify it? The main suggestion we've had so far is to write tests for each table to verify column names, constraints, etc. Has anyone else done anything similar / simpler? We're using C# with ...

junit & java : testing non-public methods

Hi all, I'm new to doing serious unit testing as well as junit. JUnit will only test those methods in my class that are public. How do I do junit testing on the ones that are not (i.e., private, protected)? I can test them by not using junit, but I was wondering what the junit standard method was. Please let me know. Thanks, jbu ...

How to set up NUnit Mock Object for IGrouping

public myReturnObj MethodA(System.Linq.IGrouping<string, MyObject> group){ ... foreach (MyObject o in group) { //business process } ... return myReturnObj; } I want to set up NUnit Mock object for passing as a paramter and then check the result of MethodA in my unittest. How do I mock this IGrouping? ...

Unit Test a class that contains an IDictionary.

I am creating a class that determines which of number of registered WCF client callbacks to call. When a client registers with the server, it supplies the token it is interested in. The class then stores a mapping of token to IClientCallback interface for that token, in a Dictionary. The method and it's class under test looks like the...

Spec. for JUnit XML Output

Where can I find the specification of JUnit's XML output. My goal is to write a UnitTest++ XML reporter which produced JUnit like output. See: "Unable to get hudson to parse JUnit test output XML" and "http://stackoverflow.com/questions/411218/hudson-c-and-unittest" ...

Unit tests by a QA Engineer

As I understood from some Q&A sessions (see this and this), unit tests should be written by developers. At my previous workplace we tried to give this task to a QA Engineer, but it didn't work. May be because it was already a middle of a project and he didn't have a chance to do a significant code coverage or may be because of another re...

How can I embed unicode string constants in a source file?

Hi all: I'm writing some unit tests which are going to verify our handling of various resources that use other character sets apart from the normal latin alphabet: Cyrilic, Hebrew etc. The problem I have is that I cannot find a way to embed the expectations in the test source file: here's an example of what I'm trying to do... /// //...

DRY between Production and Test Code Constants

I normally try to avoid duplication and adhere to the DRY principle. However, I'm wondering about a case like this: public class Feature { final static String FEATURE_LABEL = "blah"; public void doSomething() { ... } ... } public class FeatureTest { ... @Test public void doSomethingShouldMakeSomethingHappen() {...

How to do Unit Testing with Uncertainties?

We have several different optimization algorithms that produce a different result for each run. For example the goal of the optimization could be to find the minimum of a function, where 0 is the global minima. The optimization runs returns data like this: [0.1, 0.1321, 0.0921, 0.012, 0.4] Which is quite close to the global minima, so...

Log4Net works in main thread but not in created thread

In VS2008, C#, I've created a unit test (VS unit test) that calls some code which in turn calls Log4Net and logs some information. This works. If I create a thread in the unit test to call the same code I'm getting "Failed to parse config file" exception from Log4Net. Any ideas why it would not be able to parse the config file from the...

How do I write a Mock Object?

My first programming job introduced me to unit testing and the concept of mock objects, but something always felt wrong about it. Let's say we were writing a bank app, and needed to mock a BankAccount object: // boilerplate code public interface IBankAccount { void Deposit(int amount); void Withdrawal(int amoun...

Unit testing Controller.Initialize

I am setting the thread culture to the culture sent via a cookie on the HttpRequest in the initialize method of a base controller I have created. I now want to create a unit test for this functionality. In the test I have created a mock HttpContext and added the Cookie. Using this and a routeData helper, I create a RequestContext. Then ...