unit-testing

Android app unit testing

So, I'm new to android unit testing. I'm trying to write a unit test for the Phone application: package com.android.phone; import android.content.Intent; import android.net.Uri; import android.test.ApplicationTestCase; import android.test.suitebuilder.annotation.MediumTest; import com.android.phone.PhoneApp; import dalvik.annotation....

How to set up an NUnit project - Project Base and Application Base

Please forgive a very n00b question, but when using the GUI runner, Project->Edit... What directories should Project Base and Application Base point to? (Using the latest NUnit 2.5.7 and a VC# 2008 Express solution.) ...

Testing against Java EE 6 API

I write an addition to JAX-RS and included the Java EE 6 API as a Maven dependency. <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>6.0</version> <scope>provided</scope> </dependency> Then I have a little test case: @Test public void testIsWriteable() { class SpecialViewable...

Has unit/integration test without asserts right to exist?

Recently I had to chance to see a bunch of tests without any assert. Those tests had to be accuracy tests. I think the only thing that can be tested with such tests is to check if none exceptions are raised during execution flow. But anyway I really don't understand how we can verify the accuracy of the code with no asserting tests - ev...

How to resolve issue with image path when testing HtmlHelper?

I came across an issue when I was testing my HTML Helper. Basically I'm creating a grid with loads of rows, columns and different types of data in it. In the header there is also a image to notify the user what column the data is sorted by. However, when I'm writing my test now (way too late, but better late than never right?!), I get th...

How to unit test a custom actionresult

I'm trying to unit test a custom action result. I recently watched Jimmy Bogard's excellent MvcConf video ("put your controllers on a diet") http://www.viddler.com/explore/mvcconf/videos/1/ and have started to try and implement some custom action results. I've managed that without a problem, the ActionResult works fine at runtime but I'm...

How to approach unit testing in a large project

We have a project that is starting to get large, and we need to start applying Unit Tests as we start to refactor. What is the best way to apply unit tests to a project that already exists? I'm (somewhat) used to doing it from the ground up, where I write the tests in conjunction with the first lines of code onward. I'm not sure how to s...

Is it possible to unit test this method?

Hi, I have the following method for which I am trying to write a unit test: using StaticClass; // writen by some one else, have a dll namespace Test { Class TestClass { public void DoSomething(string param1) { List<string> = StaticClass.GetList(param1) // sort the list and do other studd h...

How do I run android unit tests/functional tests?

Following the "Hello, World" and "Hello, Testing" tutorials I created an android application created with Eclipse, along with a corresponding Android Test Project. The tests run fine... once. After that, in order for me to run the tests again, I have to close the emulator. If I don't close the emulator, the Eclipse console get stuck ...

Unit tests for HTML Output?

This may be a dumb question, but do you make unit tests for the HTML output of your PHP functions/scripts? I try to keep my HTML and my PHP separate - i.e. HTML includes with placeholders, and functions for certain recurring elements (tabular data / any sort of looped output) - but I'm not sure how to go about verifying this. Is there ...

QTP - JCoverage tool

Hi All, I need to integrate qtp with Cobertura, if i can do that. Just what i want is to place cobertura instrumented class on the server. Then I would be performing functional testing by qtp on this instrumented bytecode and at the same time what i want is to cobertura to capture the result so as to get code coverage. CAN I DO THIS?...

Issue With RhinoMocks - Can't Mock Return

Hello, I'm having a strange error trying to create a unit test. I'm trying to mock IPresenterFactory of the WebFormsMvp framework to force the return of a presenter. So I'm mocking it as: var view = ..; var presenter = new TestPresenter(view); var factory = mock.Stub<IPresenterFactory>(); factory.Expect(i => i.Create(null, null, null...

Dealing with TDD / Unit Testing fatigue

So I'm getting used to TDD, but I've come across an unexpected problem: I'm getting really tired of 100% code coverage. The tests are getting more tedious to write than the code itself, and I'm not sure if I'm doing it right. My question is: What sort of things are you supposed to test, and what sort of things are overkill? For example,...

How to test a before_save method including accossioations with rspec

Hi there, I'm having a problem testing the following model: class Bill < ActiveRecord::Base belongs_to :consignee before_save :calc_rate def calc_rate self.chargeableweight = self.consignee.destination.rate * self.weight end end The consignee model: class Consignee < ActiveRecord::Base belongs_to :destination has_ma...

Problem with Flex unit testing in IntelliJ

Hello, I have some problems running FlexUnit tests in IntelliJ. Every time I execute test, Internet Explorer (which is not even set as default browser) pops up and blocks unit test, i.e. blocks it as add so I must allow access through that dumb top bar and then another confirmation and then finally test runs. Is there any way to reconf...

Is it OK to copy & paste unit-tests when the logic is basically the same?

I currently have like 10 tests that test whenever my Tetris piece doesn't move left if there is a piece in the path, or a wall. Now, I will have to test the same behaviour for the right movement. Is it too bad if I just copy the 10 tests I already have for the left movement and make only the needed changes and do the same for the code i...

Why is Intellisense not working for one unit test project?

I have a Visual Studio 2008 solution which builds a C# class library (Project X) and C# Windows Application (Project Y). In the unit test project for the C# class library (XTEST) , Intellisense works as expected and auto-completes the names of classes etc. In the unit test project for the windows application (YTEST), Intellisense has ...

Should unit tests cover stress testing?

I am wondering if you guys have any good reading to consider what to classify as unit testing / acceptance / integration testing. I have the following scenario and we're having a bit of a debate at work if it should be in unit tests: In our data access layer, some statements use sql such as "select * from people where id IN ('x', 'y'), ...

How can I simplify testing of side-effect free methods in Java?

Functions (side-effect free ones) are such a fundamental building block, but I don't know of a satisfying way of testing them in Java. I'm looking for pointers to tricks that make testing them easier. Here's an example of what I want: public void setUp() { myObj = new MyObject(...); } // This is sooo 2009 and not what I want to wr...

JUnit vs TestNG

For one reason or another I've been asked to write a short summary to what the advantages and disadvantages of both JUnit and TestNG are compared to each other. Ideally I want to suggest what types of project each would be used for. I have essentially no experience with Unit Testing, so I have been reading up on each of the tools, as we...