Jump to content
Wikipedia The Free Encyclopedia

Self-testing code

From Wikipedia, the free encyclopedia

Self-testing code is software that incorporates built-in tests (see test-first development).[1] [2]


Perl packages will run their self tests when they are installed using CPAN. This ensures that they run successfully in the local environment. (There is also a testing community that tests new packages and updated packages on many different platforms.)

In Java, to execute a unit test from the command line, a class can have methods like the following.

// Executing <code>main</code> runs the unit test.
publicstaticvoidmain(String[]args){
test();
}
staticvoidtest(){
assertfoo==bar;
}

To invoke a full system test, a class can incorporate a method call.

publicstaticvoidmain(String[]args){
test();
TestSuite.test();// invokes full system test
}

In addition, Java has some Jupiter API libraries for self-testing code. assert can be used in various ways such as assert equals, which checks if the given variable is equal to the value given.

@Test
voidcheckplayer(){
Boardboard=newBoard(10);
board.addplayer(1);
intcheck=board.getCurrentPlayer(1);
assertEquals(1,check);
}

See also

[edit ]

References

[edit ]
  1. ^ "Self-testing infrastructure-as-code". OpenCredo. Retrieved 2022年12月05日.
  2. ^ "Self Testing Code". martinfowler.com. Retrieved 2022年12月05日.


Stub icon

This software-engineering-related article is a stub. You can help Wikipedia by expanding it.

AltStyle によって変換されたページ (->オリジナル) /