public int gcdint x int y gcd int
Корректные программы public int gcd(int x, int y) { gcd : int t; gcd(x, y) 0 while(y != 0) gcd(x, y)|x { t = y; gcd(x, y)|y y = x%y; z z|x z|y z|gcd(x, y) x = t; Спецификация } return (x >= 0)? x: -x; } 2 / 22
Риски, связанные с ошибками ● Космические аппараты ♦ ♦ Mariner I (1962) Фобос-1 (1988) Ariane 5 (1996) Mars Climate Orbiter (1999) ● Инфраструктура ♦ AT&T long distance network ♦ ♦ crash (1990) Northeast Blackout (2003) Open. SSL rnd in Debian (2006 -8) Heathrow Airport Terminal 5 baggage system (2008) Банковские карты Gemalt (2010) ● Автомобили ♦ Toyota Prius (2005, 2010) ● Медицинское оборудование ♦ Therac-25 (1985 -7) ♦ Medtronic Maximo (2008) ● Авионика и военное оборудование ♦ ♦ ♦ Lockheed F-117 (1982) MIM-104 Patriot (1991) Chinook ZD 576 (1994) USS Yorktown (1997) F-22 Raptor (2007) 11 / 22
Пример: описание теста @Test public class Account. Test { Account account; @State public int get. Balance() { return account. get. Balance(); } @Test @Data. Provider(name = "sums") @Guard(name = "bound“) public void test. Deposit(int x) { account. deposit(x); } @Test @Data. Provider(name = "sums") public void test. Withdraw(int x) { account. withdraw(x); } public boolean bound() { return get. Balance() < 500; } public int[] sums = new int[]{0, 1, 2, 5}; } 18 / 22
Пример работы DART int unknown_f(int x 0, int x 1) { if(x 0 == 0) return x 1; if(x 1 == 0) return x 0; if(x 0>0 && x 1<0 || x 0<0 && x 1>0) x 1 = -x 1; while(x 1 != 0) { if(x 1>x 0 && x 0>0 || x 1<x 0 && x 0<0) { x 0 = x 1 -x 0; x 1 = x 1 -x 0; x 0 = x 0+x 1; } x 1 = x 0 -x 1; x 1' = 0 x 0 = x 0 -x 1; x 0' = 1 } return x 0; x 0 x 1 Ограничение 0 0 1 0 !(x 0 = 0) && x 1 == 0 1 1 !(x 0 = 0) && !(x 1 == 0) && !(x 0>0 && x 1<0 || x 0<0 && x 1>0) && !(x 1>x 0 && x 0>0 || x 1<x 0 && x 0<0) 1 5 !(x 0 = 0) && !(x 1 == 0) && !(x 0>0 && x 1<0 || x 0<0 && x 1>0) && (x 1>x 0 && x 0 >0 || x 1<x 0 && x 0 < 0) x 0 == 0 20 / 22
Спасибо за внимание! Вопросы? http: //sp. cmc. msu. ru/specsem/vvp/ http: //www. linuxtesting. ru/ http: //www. unitesk. ru/ http: //hardware. ispras. ru/ http: //www. ispras. ru/~petrenko/ petrenko@ispras. ru http: //www. ispras. ru/~kuliamin/ kuliamin@ispras. ru 22 / 22
Общие книги по тестированию ● B. Beizer. Software Testing Techniques. Thomson Computer Press, 1990 ● R. Binder. Testing Object-Oriented Systems: Models, Patterns, and Tools. Addison-Wesley, 2000 ● P. Ammann, J. Offutt. Introduction to software testing. Cambridge University Press, 2008. 23 / 22
Модульное тестирование ● J. B. Rainsberger. JUnit Recipes. Practical Methods for Programmer Testing. Manning, 2005 ● C. Beust, H. Suleiman. Next Generation Java Testing. Test. NG and Advanced Concepts. Addison. Wesley, 2007 25 / 22
Тестирование на базе моделей ● M. Utting, B. Legeard. Practical Model-Based Testing. A Tools Approach. Morgan Kaufmann, 2006 ● J. Jacky, M. Veanes, C. Campbell, W. Schulte. Model Based Analysis and Testing with C#. Cambridge University Press, 2007 26 / 22
Теория тестирования ● M. Broy, B. Jonsson, J. -P. Katoen, M. Leucker, A. Pretschner, editors. Model Based Testing of Reactive Systems. Advanced Lectures. LNCS 3472, Springer, 2005 27 / 22
- Slides: 27