aboutsummaryrefslogtreecommitdiff
path: root/src/cz/crcs/ectester/common/test/Test.java
blob: 750a410b200edc1c816d646164ba103f0684995c (plain) (blame)
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
package cz.crcs.ectester.common.test;

import static cz.crcs.ectester.common.test.Result.Value;

/**
 * An abstract test that can be run and has a Result.
 *
 * @author Jan Jancar johny@neuromancer.sk
 */
public abstract class Test implements Testable {
    protected boolean hasRun = false;
    protected Result result;

    public Result getResult() {
        if (!hasRun) {
            return null;
        }
        return result;
    }

    public Value getResultValue() {
        if (!hasRun) {
            return null;
        }
        return result.getValue();
    }

    public String getResultCause() {
        if (!hasRun) {
            return null;
        }
        return result.getCause();
    }

    public boolean ok() {
        if (!hasRun) {
            return true;
        }
        return result.ok();
    }

    public boolean error() {
        if (!hasRun) {
            return false;
        }
        return result.compareTo(Value.ERROR);
    }

    public abstract String getDescription();

    public boolean hasRun() {
        return hasRun;
    }

    public abstract void run() throws TestException;

}