Why use Factory Bot instead of creating test data manually?

I recently taught a Rails testing class where we wrote tests using RSpec, Capybara, Factory Bot and Faker.During the class, one of the students asked, why do we use Factory Bot? What’s the advantage over creating test data manually?The answer to this is perhaps most easily explained with an example. I’m going to show an example of a test setup that creates data manually, then a test setup that uses Factory Bot, so you can see the difference.In both examples, the test setup is for a test that needs two Customer records to exist. A Customer object has several attributes and a couple associations.
Why use Factory Bot instead of creating test data manually? #ruby #rubydeveloper #rubyonrails #test https://rubyonrails.ba/single/why-use-factory-bot-instead-of-creating-test-data-manually

Nezir Zahirovic

Contractor Ruby On Rails (8+ years) / MCPD .Net / C# / Asp.Net / CSS / SQL / (11 years)

related articles