跳到内容
MathWorks

自定进度 在线课程

  • Self-Paced Content
  • MathWorks
  • MATLAB 帮助中心
  • 社区
  • 学习
  • 获取 MATLAB MATLAB
  • 登录
    • 我的帐户
    • 我的社区资料
    • 关联许可证

    • 登出
  • 联系 MathWorks 支持人员
  • Visit mathworks.com
  • 网上课程
MathWorks MathWorks

选择网站

选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。

  • (English)
  • (Deutsch)
  • (Français)
  • (简体中文)
  • (English)

您也可以从以下列表中选择网站:

如何获得最佳网站性能

选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。

美洲

  • América Latina (Español)
  • Canada (English)
  • United States (English)

欧洲

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

亚太

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文
    • English
  • 日本 (日本語)
  • 한국 (한국어)

联系您当地的办事处

image for course 单元测试

单元测试

学习编写有效的单元测试来提高代码质量,防止 Bug,并验证行为是否满足需求。理解测试概念,编写测试脚本和函数,管理测试前和测试后任务。

课程模块

Introduction

Get an overview of the content covered.

课程:
  • Course Overview
  • Learning Outcomes and Prerequisites
  • Course Example
  • What is Unit Testing?

What is a Test?

Write tests with comparisons, functions that test equality, and assert statements.

课程:
  • Elements of a Test
  • is* Functions
  • Compare with == Versus isequal
  • Test Response
  • Assert Statements

Test as You Go with a Test Script

Combine tests into a test script, and run tests on your code base.

课程:
  • Why Use a Test Script?
  • The Format of a Test Script
  • Write a Test Script
  • Test Script Results
  • Run a Test Script
  • Fix Broken Tests

Avoid Bugs in Comparisons

Use tests that make numeric comparisons within a given tolerance.

课程:
  • Bugs in Comparisons
  • Numerical Precision
  • Check for Equality (Within a Given Tolerance)
  • Add a Tolerance to Satellite Application Tests

Write Test Functions

Write test functions to test the output and behavior of programs.

课程:
  • Why Use Test Functions?
  • The Format of a Test Function
  • Convert Satellite Parameters Tests to Test Functions

Verify Behavior

Use functions that verify application behavior.

课程:
  • Verify Application Behavior
  • Verification Functions
  • Satellite Parameters Tests Using verifyTrue
  • Other verify* Functions

Test for Desired Warnings and Errors

Verify programs produce the correct warnings and errors.

课程:
  • Commands as Inputs to Test
  • Test for an Expected Error Message - Satellite Application
  • Test for an Expected Error Message - Square Root Function

Add Pre- and Post- Test Tasks

Define set-up tasks for testing, and undo them when finished.

课程:
  • What Are Pre- and Post-Test Tasks?
  • The Format of Pre- and Post- Test Tasks
  • Pre- and Post- Test Tasks for Satellite Parameters Tests

Conclusion

Review course content, learn next steps, and provide feedback on the course.

课程:
  • Summary
  • Additional Resources
  • Survey

格式:自定进度

语言:中文

语言

  • 带自动反馈的实操练习
  • 通过 Web 浏览器访问 MATLAB
  • 可共享的进度报告和课程证书

编写函数的方式和原因

通过编写自定义函数增加代码的灵活性。

  • 信任中心
  • 商标
  • 隐私政策
  • 防盗版
  • 应用程序状态
  • 联系我们

© 1994-2025 The MathWorks, Inc.