- Mastering React Test:Driven Development
- Daniel Irvine
- 78字
- 2021-06-24 14:45:03
Writing great tests
The first test now looks like this:
it('renders the customer first name', () => {
customer = { firstName: 'Ashley' };
render(<Appointment customer={customer} />);
expect(container.textContent).toMatch('Ashley');
});
This is concise and clearly readable.
A good test has three distinct sections:
- Arrange: Sets up test dependencies
- Act: Executes production code under test
- Assert: Checks expectations are met
A great test is not just good but is also the following:
- Short
- Descriptive
- Independent of other tests
- Has no side-effects
推薦閱讀
- Learning Java Functional Programming
- Learn TypeScript 3 by Building Web Applications
- AngularJS入門與進階
- Drupal 8 Blueprints
- Python完全自學教程
- Python機器學習基礎教程
- Spring Boot Cookbook
- 軟件測試綜合技術
- Natural Language Processing with Python Quick Start Guide
- 算法圖解
- Python Programming for Arduino
- Learning Kotlin by building Android Applications
- INSTANT Apache Hive Essentials How-to
- INSTANT Premium Drupal Themes
- ASP.NET Core and Angular 2