I'm finding myself needing a lot of this sort of logic lately:
Assert.That(collection.Items, Has.Member(expected_item));
Assert.That(collection.Items.Count(), Is.EqualTo(1));
I see that NUnit offers Has.Some and Has.All, but I don't see anything like Has.One. What's the best way to accomplish this without two asserts?
...
Hello,
I am trying to automate my testing procedure using Ant.
This is my error:
test:
PHPUnit 3.5.0 by Sebastian Bergmann.
unrecognized option --log-xml
/var/www/nrka2/build/build.xml:30: exec returned: 1
BUILD FAILED (total time: 1 second)
And this is my build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="eventManager...
Hello,
I'm trying to mock an interface's events like the following:
[TestMethod]
public void NeedingDataFiresEvents()
{
//Arrange
var service = MockRepository.GenerateMock<IService>();
service.Expect(i => i.GetValue()).Return(5);
var view = MockRepository.GenerateMock<ILogView>();
view.NeedData += null;
LastCall...
PHP Notice: Please no longer include "PHPUnit/Framework.php". in /usr/share/php/PHPUnit/Framework.php on line 50
Fatal error: Class 'PHPUnit_Runner_StandardTestSuiteLoader' not found in /usr/share/php/PHPUnit/TextUI/TestRunner.php on line 434
PHP Fatal error: Class 'PHPUnit_Runner_StandardTestSuiteLoader' not found in /usr/share/p...
Does anyone uses this feature of VS2010 for C++ projects? If yes could this person give some links to tutorials or explain how to do it?
...
I'm currently practising the Test-Driven Development style of programming as well as trying to memorize some useful idioms and exception safety rules I've learned. I've used an old programming assignment from semester one to simply go nuts, use stuff where it shouldn't be used to get a feel for them, learn their respective pros and cons....
Hi,
I'm trying to test if the extra_context provided by the user was correctly processed
in the view.
Here is my test approach:
# tests.py (of course it's a part of TestCase class)
def test_should_use_definied_extra_context(self):
response = self.client.get(reverse('contact_question_create'), {
'extra_context': {'foo': 'ba...
I'm trying to test sent signal and it's providing_args. Signal triggered inside contact_question_create view just after form submission.
My TestCase is something like:
def test_form_should_post_proper_data_via_signal(self):
form_data = {'name': 'Jan Nowak'}
signals.question_posted.send(sender='test', form_data=form_...
You know how they say, "There's an app for that"? Well, is there a VS plugin for this ................. ?
I want to be able to right click on a method and select "Create unit test method ..." and have it generate an nunit stub in a particular place in my project tree. So for example. I have a TheNextBigThing library with an Idea class ...
I am trying to do some Unit Testing on my program and I need to test if an array is equal to another array so I need to write the code for Assert.assertArrayEquals(a2, a3), what would this code look like?
PS: I release this function is available in JUnit 4 but I don't have a new enough version for the provided function to work so I nee...
Is there a way to create unit tests that can be run with the Visual Studio Unit Testing Framework as well as NUnit? I personally prefer the Visual Studio one, but the build server I am using only does NUnit, so I would like to support both if possible.
EDIT: To clarify, I would like to run my own tests using Visual Studio (without add-o...
Hi Guys,
Had a quick look here, couldn't find a duplicate (correct me if im wrong).
I've got the following Unit Test for some Paging with LINQ:
// Arrange.
const int locationId = 1;
const LocationType locationType = LocationType.City;
int pageSize = 10;
// Act.
var postsPageOne = PostService.FindAllPostsForLoc...
Hello,
After installing phpUnit 3.5 i am trying to run my tests this way:
phpunit AllTests.php
But I am getting the following errors:
PHP Fatal error: Class 'PHPUnit_TextUI_TestRunner' not found in /usr/share/php/PHPUnit/TextUI/Command.php on line 140
Fatal error: Class 'PHPUnit_TextUI_TestRunner' not found in /usr/share/php/PHPUni...
Hi,
I'm testing a method with quite huge sql query. I has about 15 joins, one subquery with 2 joins, so it is complex. But each running takes different time. Once it is 4 second, sometimes 80, or even 200 seconds. It is standard unit test, with preparing data with FactoryGirl, and data is always the same.
Is there any mysql profilers, m...
Is it possible to assing value to mock object. Ex:
myMockObject = context.mock(MyObject.class);
myMockObject.setId("someId");
My method which I'm testing reaches the end, but at the end there is method for validation of that object so object without id is considered to be invalid. Is there anything else I can do about this?
Can I so...
How would I determine the solution path from within my test code?
I'm trying to write tests for a plugin architecture. I have some fake classes that implement my plugin interface in a separate project within my solution. After these build, the dll is copied into a 'plugins' folder using a post-build event:
copy "$(TargetPath)" "$(Solut...
I am checking that the ModelState.IsValid in my action method that create the Employee
[HttpPost]
public virtual ActionResult Create(EmployeeForm employeeForm)
{
if (this.ModelState.IsValid)
{
try
{
IEmployee employee = this._uiFactoryInstanc...
How can i perform dependency injection without breaking encapsulation?
Using a Dependency Injection example from Wikipedia:
public Car {
public float getSpeed();
}
Note: Other methods and properties (e.g. PushBrake(), PushGas(),
SetWheelPosition() ) omitted for
clarity
This works well; you don't know how my object implem...
So, I have an XML file I am using with dbUnit as a data source, and it has some dates in it. The date in the file is like so: "2010-02-04", but once it gets loaded and I access it to print or compare in tests, it thinks the date is "2010-02-03 23:00".
I'm guessing this has to do with EDT/EST, but I'm not sure how I can force dbUnit (or...
I have a method I'd like to mock:
public interface IServiceBus
{
void Subscribe<T>(ISubscribeTo<T> subscriber) where T : class;
}
For the sake of this example, T can be something called SomeType.
Now, I'd like to mock this, like so:
var mockServiceBus = new Mock<IServiceBus>();
mockServiceBus.Setup(x => x.Subscribe(It.IsAny<ISubs...