The very common directory structure for even a simple Python module seems to be to separate the unit tests into their own test directory:
new_project/
antigravity/
antigravity.py
test/
test_antigravity.py
setup.py
etc.
for example see this Python project howto.
My question is simply What's the usual wa...
I know that this is subjective, but I'd like to follow the most common practice.
Do you normally create one test method for each class method and stuff it with multiple assertions, or do you create one test method per assertion?
For example, if I am testing a bank account's withdraw method, and I want make sure that an exception is thro...
I am working on a quite large C library that doesn't have any tests now. As the API starts to be final, I'd like to start writing unit tests.
Nearly all my functions acts on the first parameter (a structure).
The naive approach to unit test is to have the pre function call structure in a known state, call the function, and then compare...
I want to use JUnit to test Hibernate code such as insert, update, delete,.. method and transaction management.
But I don't know how to apply unit test for Hibernate usefully and what should I test with Hibernate.
How can I test DAO methods?
Hope that you could give me some guides!
...
Dear All,
I am trying to test the User.IsInRole("Administrator") in my application, and actually trying to assign the User Role to ("Administrator") so that my test will pass. I am using Scott Hanselman's MvcMockHelpers to do this, and at the moment I have the following test.
[Test]
public void Create_CanInsertNewArticleView_I...
I have an HTMLHelper extension method that outputs HTML to Response.Write. How best to unit test this?
I'm considering mocking the HtmlHelper passed into the method, but am unsure as to how I should verify the HTML sent to Response.Write.
Thanks
...
I have a Carpenter class that does it's work using a Lathe and a Wood object.
class Carpenter
{
function Work()
{
$tool = new Lathe();
$material = new Wood();
$tool->Apply($material);
}
}
Lathe depends on an interface called Material, so I can easily unit test Lathe by giving it a fake Material in my unit test. Wood doesn't d...
Hi!
When working with RIA development, there's at least three critical levels that should be tested:
RIA application classes - in Flash/Flex these could be tested using AsUnit, FlexUnit or any other JUnit-like solution
RIA application interface - in Flash/Flex this could be done using FlexMonkey
RIA application server integration - ?
...
Besides the fact that Rails incorporates the database layer into the unit tests (which then is strictly not a unit test), what if I test for model interdependencies, e.g. check if has_many/belongs_to with :dependent => :destroy really destroys the associated items or items from join models to not leave orphans around?
Should such a test...
Hi,
I have a quick question that I could not figure out in the docs about NMock2.0.
I have a function called Save() that I want to mock out. This takes a string ID as parameter and a decimal as value..
I know I can write this to make sure that Save() gets called with 2 specific values:
Expect.Once.On(dao) _
.Method("Save").Wi...
Hi,
I'm trying to choose between OCUnit and Google Tool Box, do you have any preferences, would recommend one or the other, why ?
I would be very interested to hear about your experiences with any of the 2.
The main problem i have with both of them is the managment of crashes in tested methods (ex: BAD ACCESS)
None of them was able to ...
Hi,
I have a class that inherits from System.Web.Mvc.RedirectResult which overrides ExecuteResult. How do I unit test this?
Thanks.
...
I have a class which performs several database operations, and I want to write a unit test which verifies that these operations are all performed within a transaction. What's a nice clean way to do that?
Here's some sample code illustrating the class I'm testing:
class StructureUpdater
def initialize(structure)
@structure = struc...
Maybe I am not thinking about this correctly.
I am starting my second project using unit tests. My first project I rolled my own, for this project I am trying out Boost::test.
My question is, what are the proper procedures for unit testing projects that compile into executables? It seems like everything I see out there is for librarie...
I am using the Silverlight Unit Testing Framework to test some View Manager classes. Some tests require the PropertyChanged events to be fired.
I'm currently using a combination of EnqueueConditional and WaitHandles
Example 1
[TestMethod]
[Asynchronous]
[Timeout(1000)]
public void TestNotificationExample()
{
var manager = new User...
So I'm having trouble with unit testing CakePHP models. Simple stuff like writing tests that my validation rules are catching errors etc.
To begin with, I have a model called NewsItem. Its defined in my MySQL database using the following schema
CREATE TABLE news_items (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
title VARCHAR...
I am following the hints to this question, but I'm impatient and I would like to run my tests more quickly, without having to wait for the 30+ checks that R CMD check src invokes before checking tests.
what I thought I could do was to add a --standalone option to the doRUnit.R suggested in that R-wiki page so that I could run the uni...
I have a situation I've run into several times but have never found a good answer for. Suppose I have a class like the following, where one method calls another in the same class:
public class Foo
{
public int Bar()
{
if (Baz())
{
return 1;
}
else
{
return 2;
...
I am writing a test case for my User Control which will prompt using MessageBox.Show for User Action asking to process or Cancel the operation.
How can I design my unit test to mimic the User interaction to proceed?.
I do not want to refactor to move the logic to middle tier. This is a simple case of getting User Consent and proceeding ...
We have our TeamCity builds set up using a build chain, so that our unit tests and and integration tests can run in parallel when triggered by a commit:
Build Chain - dependant on:
Unit tests
Integration tests
I am looking for a way that we can combine/merge the coverage data generated by the unit and integration tests in the build...