1 package com.atlassian.selenium;
2
3 import com.atlassian.performance.junit.PerformanceListener;
4 import com.atlassian.performance.PerformanceReporter;
5 import junit.framework.*;
6
7 import java.io.File;
8 import java.io.IOException;
9
10
11
12
13
14
15
16 public abstract class SeleniumTestSuite extends TestSuite
17 {
18
19
20
21
22
23
24 protected abstract SeleniumConfiguration getSeleniumConfiguration();
25
26
27
28
29
30
31
32 public final void run(TestResult testResult)
33 {
34 SeleniumConfiguration config = getSeleniumConfiguration();
35
36 SeleniumStarter.getInstance().start(config);
37 SeleniumStarter.getInstance().setManual(false);
38
39 PerformanceReporter reporter = new PerformanceReporter();
40
41 testResult.addListener(new PerformanceListener(reporter));
42
43 super.run(testResult);
44
45 SeleniumStarter.getInstance().stop();
46
47 if(config.getPerformanceReportLocation() != null)
48 {
49 System.out.println("SeleniumTestSuite.run log file = " + config.getPerformanceReportLocation());
50 File reportFile = new File(config.getPerformanceReportLocation());
51 try
52 {
53 reporter.writeReport(reportFile, config.getShowAutoGeneratedPerformanceEvents());
54 }
55 catch(IOException ioe)
56 {
57 throw new RuntimeException("Unable to write performance log file: " + reportFile, ioe);
58 }
59 }
60
61 }
62
63
64 }