unit-testing

Ruby unit test add a test suite to an already existing test suite

Hi, I have a test suite with me. I want to add another test class with a set of tests in the test suite. Since this is a class with test cases, I do not know how to add it to the test suite. testsuite - existing test suite. FactorTest.rb - test class with test methods (class name is FactorTest) I tried testsuite<<FactorTest and then T...

Mocking Prism Event Aggregator using Moq for Unit Testing

Hi all, I need some advice on how to use Moq in a unit test to make sure that my class under test is behaving how I want. That is the class under test publishes an Event Aggregator (from Prism) event and I need some way of asserting that this event has been raised in my test. I don't have a lot of resource at work and am finding it dif...

How do I unit-test saving file to the disk?

I know that it's strongly recommended to run unit-tests in separation from file system, because if you do touch file system in your test, you also test file system itself. OK, that's reasonable. My question is, if I want to test file saving to the disk, what do I do? As with database, I separate an interface that is responsible for datab...

Testing function signatures with ParameterTypeTuple

I'm writing a module with mixin templates to supply a main function for unit-testing purposes. Usage is as follows: /* For modules without their own main, e.g. libraries. * main is conditionally supplied using version(unittest). */ mixin Main; /* For executable modules defining function "realMain". * Generated main has the same sig...

Unit-test a controller that has a Dependency Injection in MVC

I am trying to unit test a controller that already has a constructor dependency injection. How do I also pass the dependency injection to the unit test? I am using the Ninject to do the DI in the controller but I have never unit tested anything so this is new for me. ...

Debugging code that's being tested in Visual Studio 2010

I am having some problems with a given test, that I'd like to debug the code that is being tested, while the test runs. Is this possible? If yes, how can I just debug this one test? I can only see options for running or the whole solution, or the whole set of tests in the current context or all impacted tests. I'd like to just run thi...

ruby unit testing framework UI

Hi , Is there an inbuilt UI support in the ruby unit test framework. Can i show the results of my unit test in UI? regards ...

Having trouble understanding how to use Mock in a Unit-Test

I have defined the following Unit-Test: [TestMethod] //@Test for the Java crowd public void In_The_Beginning_All_The_Board_Is_Black() { IBoard board = new Board(new Size(10, 22)); BoardEngine boardEngine = new BoardEngine(board); for (int y = 0; y < boardEngine.Size.Width; ++y) { for (int x = 0; x < boardEngine....

How to unit test UIGestureRecognizer subclasses?

Has anyone successfully unit tested subclasses of UIGestureRecognizer? What approach do you use or recommend if so? How do you go about synthesizing events if so? ...

How We Achieve isolation class under test ?

i'm start to learn unit testing. i wonder what is the best way to isolate class under test ? ...

Ruby On Rails: Testing deletes tables

Hi there! I'm creating an application in RoR and I'm implementing unit testing in all my models. When I run every test on his own (by running ruby test/unit/some_test.rb) all tests are successful. But when I run all tests together (by running rake test:units) some tables from both databases (development e test) are deleted. I'm using...

Where to place test files for unit testing

I am writing some units tests and I need to be able to access an external file. I assumed I could just place the file in my solution, mark it to be copied to the output directory, and then access it via a relative path. Unfortunately it seems that unit tests are run in a strange directory. So, instead of running from: "[MyUnitTestProj...

Integration testing, how can i wrap a REST call which changes databsae in a transaction ?

I have code like this: [Fact] public void should_return_at_least_3_users() { Rest.Call("http://localhost/admin/users/makeasfree/3"); var response = Rest.Call<List<Users>>("http://localhost/admin/freeusers"); response.Count.ShouldBeGreaterThan(0); } I've tried to surround this with TransactionScope but does not work. There is an...

Integration vs Unit Testing

Im developing with Grails. Since the framework will bootstrap data and a fully flushed out spring context, I find that I write a lot of integration tests for services. Let me rephrase that: I find I write no unit tests for services, only integration tests. Is this a bad idea? The only downside I see to it is that my tests take a bit...

Help with Unit Testing

Hi, I am new for the Unit Testing Can some one tell me where this testing class is defined in the following code and how can i find it ? #ifndef UT_USERSESSIONMANAGER_ #def UT_USERSESSIONMANAGER_ #include<gmock/gmock-genral.h> //If define in this then how can i find it #include<"pre_include.hpp"> //I am sure not define in this #incl...

Unit testing a service method- how to assert

Hello all, I'm trying to get my head around the idea of testing functionality and minimizing the number of asserts. So lets say I have such a service method: public void TransferFunds(int debitedId, int creditedId, Sum funds) { Account debited = accountRepository.Get(debitedId); Account credited = accountRepository.Get(credited...

Is this design for dependency injection easy to understand?

I'm working on a project with a large existing codebase and I've been tasked with performing some re-engineering of a small portion of it. The existing codebase does not have a lot of unit testing, but I would like at least the portion I'm working on to have a full suite of unit tests with good code coverage. Because the existing codeb...

How to create a test for Fluent nHibernate conventions?

I am creating a set of conventions for Fluent nHibernate. I create a few conventions, like primary key, foreign key and many-to-many table. I would like to be able to test out these conventions with an in memory database to see if I coded these conventions correctly. Currently, I am setting up nHibernate using an SQlite in-memory datab...

C# Unit Testing - Thread.Sleep(x) - How to Mock the System Clock

I have to test a method which does a certain amount of work after an interval. while (running) { ... // Work ... Thread.Sleep(Interval); } Interval is passed in as a parameter to the class so I can just pass in 0 or 1 but I was interested as to how to mock the system clock if this wasn't the case. In my test I'd like...

Writing test case for Junit testing

Hi, As a developer, I'm a newbie to Unit testing and have a requirement to write a test case to unit test the following code. Could somebody help me here and also give me some pointers on how to write unit tests in eclipse. private void handle(final DocumentEvent e) { Document doc = e.getDocument(); try { String tex...