Unit Testing - definitions

2020-06-20 05:20发布

Like anything else understanding the words makes it much easier to learn the language. Can anyone chime in with all the words used in unit testing with their definitions (ex. Mock, Fixture, etc. )

4条回答
家丑人穷心不美
2楼-- · 2020-06-20 05:24

Mock,

n.

  1. A type of turtle, used primarily in soup.
  2. A code construct used in Unit Testing, named after #1. A mock looks like the real thing to the code being tested, however any attempts to interact with it result only in mournful songs.

v.

  1. To construct a mock for use in testing.
查看更多
Luminary・发光体
3楼-- · 2020-06-20 05:36

This looks like a great page: http://xunitpatterns.com/Glossary.html

It includes:

  • SUT
  • synchronous test
  • task
  • TDD
  • test automater
  • test case
  • test code
  • test condition
  • test context
  • test database
  • test debt
  • test driver
  • test driving
  • test error
  • test failure
  • test fixture
  • test fixture
  • test fixture
  • test maintainer
  • test package
  • test reader
  • test result
  • test run
  • test smell
  • test stripper
  • test success
  • test suite
  • test-driven bug fixing
  • test-driven development
  • test-first development
  • test-last development
  • test-specific equality
  • test

In relation to mocking etc this might be useful:

This table and its references might be more useful:

http://xunitpatterns.com/Mocks,%20Fakes,%20Stubs%20and%20Dummies.html

查看更多
做自己的国王
4楼-- · 2020-06-20 05:38

Perhaps these articles will be more helpful:

Wikipedia:

In computer programming, unit testing is a software design and development method where the programmer gains confidence that individual units of source code are fit for use. A unit is the smallest testable part of an application. In procedural programming a unit may be an individual program, function, procedure, etc., while in object-oriented programming, the smallest unit is a method, which may belong to a base/super class, abstract class or derived/child class.

Unit testing can be done by something as simple as stepping through code in a debugger; modern applications include the use of a test framework such as xUnit.

Ideally, each test case is independent from the others; Double objects like stubs, mock or fake objects1 as well as test harnesses can be used to assist testing a module in isolation. Unit testing is typically done by software developers to ensure that the code other developers have written meets software requirements and behaves as the developer intended.

MSDN:

The primary goal of unit testing is to take the smallest piece of testable software in the application, isolate it from the remainder of the code, and determine whether it behaves exactly as you expect. Each unit is tested separately before integrating them into modules to test the interfaces between modules. Unit testing has proven its value in that a large percentage of defects are identified during its use.

Extreme Rules:

Unit tests enable collective code ownership. When you create unit tests you guard your functionality from being accidentally harmed. Requiring all code to pass all unit tests before it can be released ensures all functionality always works. Code ownership is not required if all classes are guarded by unit tests.

查看更多
一夜七次
5楼-- · 2020-06-20 05:47

I've also found a glossary of testing terms, but it doesn't define Mock or Fixture, but there's an option to add new ones. Once the question is answered to your satisfaction maybe that could become the canonical source.

查看更多
登录 后发表回答