blob: 5060d2f5425084dfad0a94db4a476a5f281bc61b [file] [log] [blame]
Stuart McCulloch26e7a5a2011-10-17 10:31:43 +00001package aQute.bnd.build;
2
3import java.io.*;
4import java.util.*;
5
6public abstract class ProjectTester {
7 final Project project;
8 final Collection<Container> testbundles;
9 final ProjectLauncher launcher;
10 final List<String> tests = new ArrayList<String>();
11 File reportDir;
12 boolean continuous = true;
13
14 public ProjectTester(Project project) throws Exception {
15 this.project = project;
16 launcher = project.getProjectLauncher();
17 testbundles = project.getTestpath();
18 for (Container c : testbundles) {
19 launcher.addClasspath(c);
20 }
21 reportDir = new File(project.getTarget(), project.getProperty("test-reports",
22 "test-reports"));
23 }
24
25 public ProjectLauncher getProjectLauncher() {
26 return launcher;
27 }
28
29 public void addTest(String test) {
30 tests.add(test);
31 }
32
33 public Collection<String> getTests() {
34 return tests;
35 }
36
37 public Collection<File> getReports() {
38 List<File> reports = new ArrayList<File>();
39 for (File report : reportDir.listFiles()) {
40 if (report.isFile() )
41 reports.add(report);
42 }
43 return reports;
44 }
45
46 public File getReportDir() {
47 return reportDir;
48 }
49
50 public void setReportDir(File reportDir) {
51 this.reportDir = reportDir;
52 }
53
54 public Project getProject() {
55 return project;
56 }
57
58 public boolean getContinuous() {
59 return continuous;
60 }
61
62 public void setContinuous(boolean b) {
63 this.continuous = b;
64 }
65
66 public boolean prepare() throws Exception {
67 reportDir.mkdirs();
68 for ( File file : reportDir.listFiles() ) {
69 file.delete();
70 }
71 return true;
72 }
73
74 public abstract int test() throws Exception;
75}