Skip to Content
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
Explore Skills
Cloud Computing
Microsoft Azure
Amazon Web Services (AWS)
Google Cloud
Cloud Migration
Cloud Deployment
Cloud Platforms
Data Engineering
Data Warehouse
SQL
Apache Spark
Microsoft SQL Server
MySQL
Kafka
Data Lake
Streaming & Messaging
NoSQL Databases
Relational Databases
Data Science
Pandas
R
MATLAB
SAS
D3
Power BI
Tableau
Statistics
Exploratory Data Analysis
Data Visualization
AI & ML
Generative AI
Machine Learning
Artificial Intelligence (AI)
Deep Learning
Reinforcement Learning
Natural Language Processing
TensorFlow
Scikit-Learn
Hyperparameter Tuning
MLOps
Programming Languages
Java
JavaScript
Spring
Python
Go
C#
C++
C
Swift
Rust
Functional Programming
Software Architecture
Object-Oriented
Distributed Systems
Domain-Driven Design
Architectural Patterns
IT/Ops
Kubernetes
Docker
GitHub
Terraform
Continuous Delivery
Continuous Integration
Database Administration
Computer Networking
Operating Systems
IT Certifications
Security
Network Security
Application Security
Incident Response
Zero Trust Model
Disaster Recovery
Penetration Testing / Ethical Hacking
Governance
Malware
Security Architecture
Security Engineering
Security Certifications
Design
Web Design
Graphic Design
Interaction Design
Film & Video
User Experience (UX)
Design Process
Design Tools
Business
Agile
Project Management
Product Management
Marketing
Human Resources
Finance
Team Management
Business Strategy
Digital Transformation
Organizational Leadership
Soft Skills
Professional Communication
Emotional Intelligence
Presentation Skills
Innovation
Critical Thinking
Public Speaking
Collaboration
Personal Productivity
Confidence / Motivation
Features
All features
Verifiable skills
AI Academy
Courses
Certifications
Interactive learning
Live events
Superstreams
Answers
Insights reporting
Radar Blog
Buy Courses
Plans
Sign In
Try Now
O'Reilly Platform
book
React学习手册
by
Alex Banks
,
Eve Porcello
December 2017
Intermediate to advanced
329 pages
6h 9m
Chinese
China Electric Power Press Ltd.
Content preview from
React学习手册
测试
|
227
编写最少量的必需代码,让它们通过测试(绿色)
现在,用户必须做的事情就是跑通测试用例。重点放在让每个测试通过上面,并
且不要添加任何超过测试范围的功能。
重构上述程序代码和测试用例(金色)
一旦测试通过,那么就是该认真检查项目代码和测试用例的时候了,尽量将项目
代码变得简洁优雅。
注
2
TDD
是处理
Redux
应用程序绝佳方式。在编写实际的
Reducer
之前,通常更容易理解该
Reducer
的工作机制。践行
TDD
将允许用户独立于
UI
之外,构建和验证某个功能特性
或者应用程序的整个数据结构。
TDD
新手进阶技巧
如果你是一名
TDD
新手,或者对于正在测试的语言比较陌生,可能会发现在编
写代码之前就编写测试用例非常具有挑战性。这是可以预见的,在你成为
TDD
老手之前,在测试之前编写项目代码并没有什么问题。先尝试一些小批量的测
试:一小段代码,几个测试用例等。一旦可以熟练地编写测试用例之后,那么
先写测试用例将会更容易一些。
本章需要提醒读者的是,我们将为已存在的代码编写测试。从技术上来说,我们并不
是在践行
TDD
。不过,在下一节中我们将会假定项目代码不存在,以便让我们感受一
下
TDD
工作流程。
测试
Reducer
Reducer
是根据输入参数进行一系列计算并返回结果的纯函数。在一个测试中,我们
可以控制输入、当前
State
和
Action
。给定一个当前的
State
和
Action
,我们将能预计一
个
Reducer
的输出结果。
在我们开始编写测试代码之前,将需要安装一个测试框架。用户可以使用任意
JavaScript
测试框架为 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial
You might also like
React快速上手开发
Stoyan Stefanov
流畅的Python
Luciano Ramalho
C++语言导学(原书第2版)
本贾尼 斯特劳斯特鲁普
C++程序设计:原理与实践(基础篇)(原书第2版)
本贾尼 斯特劳斯特鲁普
Publisher Resources
ISBN: 9787519814236