In this lesson, we will not write code but look at a typical "plan" behind every test method.
One of the most common ways to write tests is to divide any function into three phases, and they all start with an "A" letter. It's a "AAA". You can call it a 3-step framework:
- Arrange
- Act
- Assert
In most cases, you should stick to this plan for every function in your test.
Step 1. Arrange.
You can call it a "preparation" step.
Add any data you need, any configuration. Build the scenario.
test('homepage contains non empty table', function () { Product::create([ 'name' => 'Product 1', 'price' => 123, ]); get('/products') ->assertStatus(200) ->assertDontSee(__('No products found'));});
Step 2. Act.
This step is usually about...
Could you kindly also indicate in the image which stage you are referring to?
Sorry, could you explain what do you mean by this?
Vance is probabbly referring to the PEST code where same code is used under Arrange, Act and Assert without any parts being bolded or otherwise marked. Though I doubt this will confuse many, you might just want to put 1 example with comments:
From this pag, nobody can unserstand what is Arrange, Act, Assert.
@Zhtekdev
Arrange = create the data scenario (whatever it might be) Act = do the thing you want to test Assert = check the result is what you expect
Theres no extra hidden things here..I think the page repeats it to help the person LEARN by seeing already it's in 3 clear sections and there's 3 clear sections of code. For me I think this is totally fair in this case.