unit-testing

How can I use PHPUnit to set up and tear down the database using a SQL file?

I have a MySQL file that represents my database in a specific state that would allow me to test a class I am working on. What I want to do is have PHPUnit clean and rebuild the database from this file for each test or set of tests. How can I go about that without having to resort to rewriting the data in the XML format that PHPUnit uses...

Getting path of file copied after deployment in a unit test

The connection string in my app.config for my C# project looks like Data Source=.\SQLEXPRESS;AttachDbFilename='|DataDirectory|\EIC.mdf';Integrated Security=True;User Instance=True" I am writing unit tests for the project and have the set the test run configuration to copy the EIC.mdf, but I do am not able to reference the Deployed cop...

How can I get started with PHPUnit, where my class construct requires a preconfigured db connection?

I have a class that uses a lot of database internally, so I built the constructor with a $db handle that I am supposed to pass to it. I am just getting started with PHPUnit, and I am not sure how I should go ahead and pass the database handle through setup. // Test code public function setUp(/*do I pass a database handle through here,...

Which unit test framework in VS2010 - MSTest or NUnit?

Possible Duplicates: Ms Test or NUnit? NUnit vs Visual Studio 2008s Test Projects for Unit Testing? what test data approach/framework is recommended for .net unit testing Are there real differences between NUnit and Microsofts Unit Testing Framework (VS 2008)? Any recommendations re whether to got MSTest or NUnit for a ...

what test data approach/framework is recommended for .net unit testing

Hi, what test data approach/framework is recommended for .net unit testing? I'm in VS2010, C#, doing business logic layer testing. By approaches I mean like: creating database snapshots, programmatically creating each time, etc etc. Like what approach to use to ensure at the start of each test the database is in a known state. ...

Does PHPUnit have some inbuilt recursive array comparison function?

Some of the testing I will need to do will require comparing a known array with the result I am getting from the functions I will be running. For comparing arrays recursively: Does PHPUnit have an inbuilt function? Does someone here have some code they have constructed to share? Will this be something I will have to construct on my ...

How do I work with constructs in PHPUnit?

I am new into PHPUnit, and just digging through the manual. I cannot find a decent example of how to build a complete test from end to end though, and so, am left with questions. One of these is how can I prep my environment to properly test my code? I am trying to figure out how to properly pass various configuration values needed for...

Populating an association with children in factory_girl

I have a model Foo that has_many 'Bar'. I have a factory_girl factory for each of these objects. The factory for Bar has an association to Foo; it will instantiate a Foo when it creates the Bar. I'd like a Factory that creates a Foo that contains a Bar. Ideally this Bar would be created through the :bar factory, and respect the build st...

eclEmma - full code coverage on class header?

Hi, I have a class that starts with: public class GeneralID implements WritableComparable<GeneralID>{ ... } And another that is: public class LineValuesMapper<KI, VI, KO, VO> extends Mapper<LongWritable, Text, Text, IntWritable>{ ... } All methods in these classes are covered. But not their header. The header of both classes gets ...

JUnit Test method with randomized nature

Hey, I'm working on a small project for myself at the moment and I'm using it as an opportunity to get acquainted with unit testing and maintaining proper documentation. I have a Deck class with represents a deck of cards (it's very simple and, to be honest, I can be sure that it works without a unit test, but like I said I'm getting u...

jsfunit with junit 4

Hi, We would like to test our web application (jsf 1.2, richfaces 3.3.3) with jsfunit. We are using junit 4.8.1 library for our unit tests. But jsfunit (1.2.0.Final) requires non existing class junit.runner.TestSuiteLoader. If i downgrade to junit 3.8, i can't use annotations in my Test classes any more. Is there a solution for it? Th...

Automated testing for Facebook SDK wrapper

Hi there! In my Facebook application, I have one Facebook wrapper class to encapsulates some call to Facebook API. I want to to write a unit test for this wrapper class, but since it depends on a so called "access token", which we should get from Facebook dynamically, I'm not sure if it's possible to write one. But apparently the Faceb...

RSpec test failing looking for a new set of eyes

Guys, Here my issuse: I've got two models: class User < ActiveRecord::Base # Setup accessible (or protected) attributes for your model attr_accessible :email, :username has_many :tasks end class Task < ActiveRecord::Base belongs_to :user end with this simple routes.rb file TestProj::Application.routes.draw do |map| res...

Test cases for a database manager in C#

Hallo all, I just start my carrier after graduation. My first testing task is to test a program which is used as an interface to edit a database. This program is coded in C#. Except some reading of a couple of online tutorials on C#, I have really little concrete experience with this kind of sw test. It seems that I have to add some Tes...

Asp.Net MVC How to test that the view rendered

HI there I was wondering if there is a better way of testing that a view has rendered in MVC. I was thinking perhaps I should render the view to a string but perhaps there are simpler methods? Basically what I want to know if that the view for a given action has rendered without errors I m already testing the view model but I want t...

How can I tell JWebUnit to contact specific Selenium servers

We want to run selenium backed jwebunit tests from our hudson server. We have a couple of selenium rc servers already on our network which I'd like to reuse. However how can I configure jwebunit to use those servers as I would like to avoid installing a slenium rc server on the hudson. Building is already work enough without starting/st...

Weird error when trying to test method with argument in Mocha. Is it a bug or is it me?

Hi there. It's rather hard to find any documentation on Mocha, so I'm afraid I'm totally at sea here. I have found a problem with stubbing methods that pass arguments. So for instance if I set up a class like this: class Red def gets(*args) @input.gets(*args) end def puts(*args) @output.puts(*args) end def initial...

Unit testing nested subflows (subflows of subflows)

I'm trying to write unit test for a flow, which has subflow, which, itself, has another subflow. I register first flow using FlowDefinitionResource getResource(FlowDefinitionResourceFactory resourceFactory). Then I register subflow definitions during test execution in FlowDefinitionRegistry before transitioning to them. Transitioning ...

Why am I getting "ArgumentError: wrong number of arguments (1 for 0)" when running my rails functional tests?

I'm stumped on what's causing this. I get this error and stack trace in all my functional tests where I call 'post'. Here is the full stack trace: 7) Error: test_should_validate(UsersControllerTest): ArgumentError: wrong number of arguments (1 for 0) /Users/hisham/src/rails/ftuBackend/vendor/rails/actionpack/lib/action_controller/...

Value of Step-by-Step Asserts in Unit Tests

When writing unit tests, there are cases where one can create an Assert for each condition that could fail or an Assert that would catch all such conditions. C# Example: Dictionary<string, string> dict = LoadDictionary(); // Optional Asserts: Assert.IsNotNull(dict, "LoadDictionary() returned null"); Assert.IsTrue(dict.Count > 0, "Dicti...