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
2
votes
1 answer

How can I set the returned value of this Stub object?

public interface IMyINterface { int GetMeSomeInteger(); Toy GetMeAToy(string toyName); } [TestMethod] public void PlayWithANumber_RecievesInteger_DoRightJob() { IMyINterface stub = MockRepository.GenerateStub(); //…
pencilCake
  • 51,323
  • 85
  • 226
  • 363
2
votes
1 answer

How to arrange data rows in by specific order of a particular grouping variable level in r

I want to know how to arrange data rows in by specific order of a particular grouping variable level in r. Using the mtcars dataset, I want to create a data frame, called mtcars_arrange where rows are first organized by gear values in the following…
Mel
  • 510
  • 3
  • 10
2
votes
3 answers

RhinoMocks AAA Syntax

I've spent a good part of the day trying to figure out why a simple RhinoMocks test doesn't return the value I'm setting in the return. I'm sure that I'm just missing something really simple but I can't figure it out. Here's my test: …
Bill Campbell
  • 2,413
  • 6
  • 27
  • 32
2
votes
2 answers

Xunit: Perform all 'Assert'ions in one test method?

Is it possible to tell xUnit.net to perform all e.g. Assert.True() in one test method? Basically in some of our use/testcases all assertions belong logically to one and the same 'scope' of tests and I have e.g. something like this: …
Jörg Battermann
  • 4,044
  • 5
  • 42
  • 79
1
vote
1 answer

Using the Arrange Act Assert pattern with Integration Tests

Using the Arrange Act Assert what should be in the Arrange "section" considering that this is an integration test on my database? private void Delete_Release_Test_Data(string conString) { UnitTestHelper.PrepareData(new[] {…
Pascal
  • 12,265
  • 25
  • 103
  • 195
1
vote
2 answers

(in R) how to arrange column A based on column B

I got a data frame like this: Factory Bread A a A a B c B b B d C a D e I want to find name of the factory with the most number of bread I write two codes and got different answers. 1. df %>% group_by(factory, bread)%>% …
island1996
  • 47
  • 5
1
vote
0 answers

Where and when should data be inserted into a database in the arrange phase in xunit framework?

Where and when should data be inserted into a database in the arrange phase in xunit framework? By the arrange phase I mean the Arrange from the Arrange, Act, Assert pattern. To prepare data for each test method I am using a separate class.…
hellouworld
  • 525
  • 6
  • 15
1
vote
2 answers

Which style exists for mocking with Rhino?

I heard that latest style is AAA. Is there any other one? Why we use one and don't use another?
Afshar Mohebi
  • 10,479
  • 17
  • 82
  • 126
1
vote
1 answer

AAA- Unit testing file IO - logging

I am writing a custom logger for a program. I am using NLog as much as possible. I am looking to verify functionality and have written some unit tests using the AAA pattern. However this causes the problem with Assert.... How can I/Whats the best…
asuppa
  • 571
  • 1
  • 11
  • 27
1
vote
2 answers

JustMock - How to mock a method for all instances by returning the result of the equivalent method of another class (sharing a common interface

I am working with .NET 4.5, EF6 and I'm trying to use JustMock 2.0 to test my application. I am trying to mock my database by mocking my DbContext subclass: CoreDataRepositoryContext. To do it, I need to mock the member SaveChanges of DbContext and…
Valone
  • 41
  • 7
1
vote
1 answer

Given-When-Then when dealing with User Input

I'm looking for some clarification regarding Arrange/Act/Assert, which I'm implementing in my development process as Given-When-Then. I try to stick to the concept, but I'm finding that during certain events (particularly user input), I have to…
Arclight
  • 493
  • 4
  • 18
0
votes
1 answer

Create new column which orders two previous columns

I'm looking to create a new column which is based on the ordering of two other columns, preferably using the Tidyverse functions, but any suggestions are appreciated. I have a table of around 1300 entries and several columns but a sample of my data…
0
votes
0 answers

Can AAA be used in Automation Tests?

I have a smoke test suite, which will be automated. Can I use during code process Act Arrange Assert Pattern? Or Is it only for unit testing? Or is there better pattern for automation testing?
0
votes
0 answers

Is it possible to use TestCases in FluidAssertions to combine tests that check against different unique exception types?

I am trying to simplify my unit test code by utilizing [TestCase] instead of multiple [Test] methods. The functioning, bulky example of an implementation is as follows: [Test] public void Uri_Cannot_Be_Resolved_By_Not_Passing_A_Valid_Uri() { …
0
votes
1 answer

Is it okey to DRY the action of a test?

From my understanding of AAA - arrange act assert, it is important to make it clear what code is for arranging, acting and asserting. When testing a complex scenario, I am used to having multiple times the same action, every test. The arranging…
Hector Ordonez
  • 1,044
  • 1
  • 12
  • 20