Questions tagged [arrange-act-assert]

A pattern for structuring a unit test.

This pattern divides each unit test into three sections, separated by blank lines:

  1. Arrange all necessary preconditions and inputs.
  2. Act on the object or method under test.
  3. Assert that the expected results have occurred.

Organizing tests in this way makes them easier to read and understand.

The pattern was observed and named by Bill Wake in 2001.

"Arrange-Act-Assert syntax" or "AAA syntax" also refers to a Rhino Mocks syntax which supports this pattern.

41 questions
0
votes
2 answers

Python DataFrame: rearrange the objects and empty values

I have a Python DataFrame with 20000+ values as below. And I want to efficiently rearrange df with NaN goes after string of values. IT1 IT2 IT3 IT4 IT5 IT6 0 qwe NaN NaN rew NaN NaN 1 NaN NaN …
EJ Kang
  • 455
  • 2
  • 5
  • 17
0
votes
1 answer

How can I write this simple test in AAA Syntax with Rhino Mocks framework?

How can I write this simple Record-and-replay based test in AAA Syntax with Rhino Mocks framework? public interface IStudentReporter { void PrintStudentReport(List students); List GetUnGraduatedStudents(List
pencilCake
  • 51,323
  • 85
  • 226
  • 363
0
votes
1 answer

How to mock arbitrary behavior with Rhino Mocks?

I'm trying to mock a data layer method. The method takes a string and two lists as arguments, and the method populates those lists from the results of a stored proc. Also, I'm still on C# 2.0 with VS2005, and I'm using Rhino Mocks 3.5 for .NET 2.0.…
bwerks
  • 8,651
  • 14
  • 68
  • 100
0
votes
2 answers

Assert that value has been assigned before method call

I'm using the AAA-pattern and Rhino mocks for my unit-testing. I want to assert that a specific value (e-mail) has been set on an entity before I call SaveChanges() on DbContext. I have a test-method which looks like this: protected override void…
smoksnes
  • 10,509
  • 4
  • 49
  • 74
0
votes
3 answers

I'm learning unit testing and wonder if this Unit test program flow is correct? as in Arrange, Act, Assert

I'm learning unit testing and wonder if this Unit test program flow (as in Arrange, Act, Assert) is correct? [TestFixture] public class unitTest2 { private CoffeeMaker coffemaker; [Test] public void TestMethod1() // Testa metoden…
Dan A
  • 107
  • 2
  • 2
  • 7
0
votes
2 answers

code-coverage of the getter through the assert

While unit-testing, is there a way to enable code-coverage analysis only during some steps? I wish to measure the code-coverage of the assert part of a test. The tools that I currently use don't make the difference if the line is executed during the…
sab
  • 4,352
  • 7
  • 36
  • 60
0
votes
2 answers

Is there a way to cache an Arg.Is<> definition for use in both the "Arrange" and "Act" parts of a test?

I have a test that looks like this: [Test] public void Blah() { // Arrange // ... var thing = new Thing(); mockRouter.Route(Arg.Is>(x => x != null && x.Subject != null &&…
Kit
  • 20,354
  • 4
  • 60
  • 103
0
votes
1 answer

Clear call history of a mock

question: is it possible to clear the call history of a mock (or stub)? ( and with call history I don't mean the expected / recorded behaviour.) The details: I currently want am writing the following code with tests according the AAA syntax using…
TJ Galama
  • 457
  • 3
  • 12
0
votes
5 answers

When is it OK to group similar unit tests?

I'm writing unit tests for a simple IsBoolean(x) function to test if a value is boolean. There's 16 different values I want to test. Will I be burnt in hell, or mocked ruthlessly by the .NET programming community (which would be worse?), if I don't…
Brendan Hill
  • 3,406
  • 4
  • 32
  • 61
0
votes
1 answer

Rhino Mock AAA expectation inside of expectation

Is it possible to mock the following situation, using Rhino Mock AAA syntax: // Interface interface IFoo { void ExecuteFoo( Expression action ); void Increment(out int value); // value++ } // Situation to mock: var foo = new…
Joanna
  • 81
  • 3
-3
votes
1 answer

it is correct to use setup in unit test C#

I am explaining better, I am studying how to do unit tests in C # with NUnit and justmock. I am reading the book the art of unit tests, Here I am told that whenever possible try to avoid [SetUp] for a previous scenario configuration a try. But…
Johan
  • 60
  • 8
1 2
3