summaryrefslogtreecommitdiff
path: root/sem_5/HLIN505_Java/HLIN505/src/foobar/TestParametreFoo.java
blob: 9b117d5bcb8e96371656b8ba0f96c993d7188489 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package foobar;

import static org.junit.Assert.*;

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

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

import static org.hamcrest.CoreMatchers.is;

@RunWith(Parameterized.class)
public class TestParametreFoo {

	private static SUT sut;
	private int x;
	private int y;
	private int z;
	private int t;
	private int res;
	
	@Parameters
    public static Collection data() {
        return Arrays.asList(new Object[][]{
                {-1, 3, 5, 2, 3},
                {5, 5, 5, 2, 5},
                {5, 5, 3, 2, 5},
                {3, 3, 5, 2, 3},
                {3, 3, 3, 2, 3},
                {1, 5, 3, 2, 5}
        });
    }
	
	
	public TestParametreFoo(int x, int y, int z, int t, int res) {
		this.x = x;
		this.y = y;
		this.z = z;
		this.res = res;
		this.t=t;
	}


	@Before
	public void setUp() throws Exception {
	}

	@Test
	public void testFoo() {
		sut=new SUT(x, y, z);
		assertThat(sut.foo(t), is(res));
	}
	
	@Test(expected=FooBarException.class)
	public void TestFoobarexcept () throws FooBarException {
		sut=new SUT(-1, 12, 26);
		sut.foobar();
	}
}