Что такое findslide.org?

FindSlide.org - это сайт презентаций, докладов, шаблонов в формате PowerPoint.


Для правообладателей

Обратная связь

Email: Нажмите что бы посмотреть 

Яндекс.Метрика

Презентация на тему Введение. Unit тестирование. (Тема 1.4)

Unit тестирование
I. Введение4. Unit тестирование Unit тестирование Библиотека JUnit JUnit Загрузка JUnit Структура директорий JUnit Библиотека “Калькулятор!”package org.cud.calc;public class Calculator {  public int sum(int... numbers) { Компиляция библиотекиI:\>dir src\org\cud\calc Volume in drive I has no label. Volume Serial Тестpackage org.cud.calc;import static org.junit.Assert.assertEquals;import org.junit.Test;public class CalculatorTest {  @Test  public Компиляция тестаI:\>dir test\org\cud\calc Volume in drive I has no label. Volume Serial Запуск тестаI:\>java -cp lib/junit-4.8.2.jar;test_bin;bin org.junit.runner.JUnitCore org.cud.calc.CalculatorTestJUnit version 4.8.2.Time: 0OK (1 test)I:\> Параметризованный тестpackage org.cud.calc;import static org.junit.Assert.assertEquals;import org.junit.Test;import org.junit.runner.RunWith;import org.junit.runners.Parameterized.Parameters;import java.util.Arrays;import java.util.Collection;@RunWith(value = org.junit.runners.Parameterized.class)public Компиляция параметризованного тестаI:\>dir test\org\cud\calc Volume in drive I has no label. Volume Запуск параметризованного тестаI:\>java -cp lib/junit-4.8.2.jar;test_bin;bin org.junit.runner.JUnitCore org.cud.calc.CalculatorParamTestJUnit version 4.8.2.....Time: 0.015OK (5 tests)I:\>
Слайды презентации

Слайд 2 Unit тестирование

Unit тестирование

Слайд 3

Библиотека JUnit

Библиотека JUnit

Слайд 4 JUnit

JUnit

Слайд 5 Загрузка JUnit

Загрузка JUnit

Слайд 6 Структура директорий

Структура директорий

Слайд 7 JUnit

JUnit

Слайд 8 Библиотека “Калькулятор!”
package org.cud.calc;

public class Calculator {

public

Библиотека “Калькулятор!”package org.cud.calc;public class Calculator { public int sum(int... numbers) {

int sum(int... numbers) {

int total

= 0;

for (int i : numbers) {

total += i;
}
return total;
}
}



Слайд 9 Компиляция библиотеки
I:\>dir src\org\cud\calc
Volume in drive I has

Компиляция библиотекиI:\>dir src\org\cud\calc Volume in drive I has no label. Volume

no label.
Volume Serial Number is 8009-8B63

Directory of

I:\src\org\cud\calc

01/13/2013 12:56 PM .
01/13/2013 12:56 PM ..
11/14/2012 05:00 PM 185 Calculator.java
1 File(s) 185 bytes
2 Dir(s) 237,193,134,080 bytes free

I:\>javac -d bin src\org\cud\calc\Calculator.java

I:\>dir bin\org\cud\calc
Volume in drive I has no label.
Volume Serial Number is 8009-8B63

Directory of I:\bin\org\cud\calc

01/13/2013 12:56 PM .
01/13/2013 12:56 PM ..
01/13/2013 05:40 PM 369 Calculator.class
1 File(s) 369 bytes
2 Dir(s) 237,193,134,080 bytes free

I:\>



Слайд 10 Тест
package org.cud.calc;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class CalculatorTest {

Тестpackage org.cud.calc;import static org.junit.Assert.assertEquals;import org.junit.Test;public class CalculatorTest { @Test public void

@Test
public void test() {

Calculator calculator = new Calculator();

assertEquals(9, calculator.sum(2, 3, 4));
}
}



Слайд 11 Компиляция теста
I:\>dir test\org\cud\calc
Volume in drive I has

Компиляция тестаI:\>dir test\org\cud\calc Volume in drive I has no label. Volume

no label.
Volume Serial Number is 8009-8B63

Directory of

I:\test\org\cud\calc

01/13/2013 05:50 PM .
01/13/2013 05:50 PM ..
11/14/2012 05:21 PM 256 CalculatorTest.java
1 File(s) 256 bytes
2 Dir(s) 237,193,125,888 bytes free



I:\>javac -d test_bin -cp lib/junit-4.8.2.jar;bin test\org\cud\calc\CalculatorTest.java

I:\>dir test_bin\org\cud\calc
Volume in drive I has no label.
Volume Serial Number is 8009-8B63

Directory of I:\test_bin\org\cud\calc

01/13/2013 06:42 PM .
01/13/2013 06:42 PM ..
01/13/2013 06:42 PM 484 CalculatorTest.class
1 File(s) 484 bytes
2 Dir(s) 237,193,125,888 bytes free

I:\>



Слайд 12 Запуск теста
I:\>java -cp lib/junit-4.8.2.jar;test_bin;bin org.junit.runner.JUnitCore org.cud.calc.CalculatorTest
JUnit version 4.8.2
.
Time:

Запуск тестаI:\>java -cp lib/junit-4.8.2.jar;test_bin;bin org.junit.runner.JUnitCore org.cud.calc.CalculatorTestJUnit version 4.8.2.Time: 0OK (1 test)I:\>

0

OK (1 test)

I:\>


Слайд 13 Параметризованный тест
package org.cud.calc;

import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized.Parameters;

import

Параметризованный тестpackage org.cud.calc;import static org.junit.Assert.assertEquals;import org.junit.Test;import org.junit.runner.RunWith;import org.junit.runners.Parameterized.Parameters;import java.util.Arrays;import java.util.Collection;@RunWith(value =

java.util.Arrays;
import java.util.Collection;

@RunWith(value = org.junit.runners.Parameterized.class)
public class CalculatorParamTest {
int

result;
int[] numbers;

@Parameters
public static Collection parameters() {

return Arrays.asList(new int[][][] { { { 2 }, { 1, 1 } },
{ { -2 }, { -1, -1 } }, { { 9 }, { 2, 3, 4 } }, { { 0 }, {} },
{ { 0 }, { 0, 0, 0, 0 } } });
}

public CalculatorParamTest(int[] result, int[] numbers) {
this.result = result[0];
this.numbers = numbers;
}

@Test
public void testSum() {
Calculator calculator = new Calculator();
assertEquals(result, calculator.sum(numbers));
}
}



Слайд 14 Компиляция параметризованного теста
I:\>dir test\org\cud\calc
Volume in drive I

Компиляция параметризованного тестаI:\>dir test\org\cud\calc Volume in drive I has no label.

has no label.
Volume Serial Number is 8009-8B63

Directory

of I:\test\org\cud\calc

01/13/2013 07:16 PM .
01/13/2013 07:16 PM ..
11/14/2012 05:32 PM 881 CalculatorParamTest.java
1 File(s) 881 bytes
2 Dir(s) 237,193,134,080 bytes free





I:\>javac -d test_bin -classpath lib/junit-4.8.2.jar;bin test\org\cud\calc\CalculatorParamTest.java



I:\>dir test_bin\org\cud\calc
Volume in drive I has no label.
Volume Serial Number is 8009-8B63

Directory of I:\test_bin\org\cud\calc

01/13/2013 07:46 PM .
01/13/2013 07:46 PM ..
01/13/2013 07:46 PM 1,247 CalculatorParamTest.class
1 File(s) 1,247 bytes
2 Dir(s) 237,193,113,600 bytes free

I:\>



  • Имя файла: vvedenie-unit-testirovanie-tema-14.pptx
  • Количество просмотров: 134
  • Количество скачиваний: 0