File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using System ;
22using Desktop . Tests . e2e . Drivers ;
3+ using Desktop . Tests . e2e . Utils ;
34
45namespace Desktop . Tests . e2e ;
56
67public class AppActions : IDisposable
78{
8- private readonly MainWindowDriver mainWindow = new ( ) ;
9+ private readonly MainWindowDriver mainWindow ;
10+ private readonly BackendLauncher backendLauncher ;
11+
12+ public AppActions ( )
13+ {
14+ backendLauncher = new BackendLauncher ( ) ;
15+ backendLauncher . Launch ( ) ;
16+
17+ mainWindow = new MainWindowDriver ( ) ;
18+ }
919
1020 public void Dispose ( )
1121 {
22+ backendLauncher . Dispose ( ) ;
1223 mainWindow . Dispose ( ) ;
1324 }
1425
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Diagnostics ;
3+ using System . IO ;
4+
5+ namespace Desktop . Tests . e2e . Utils ;
6+
7+ public class BackendLauncher : IDisposable
8+ {
9+ private Process process ;
10+
11+ /// <remarks>
12+ /// This is a tentative approach. It is error-prone, fragile and couples both
13+ /// the location of the Backend and its execution to the same machine that the
14+ /// Desktop app is running for the test.
15+ /// <para>
16+ /// Ideally, the desired version of the Backend to test will be deployed in
17+ /// a Docker container by the CI/CD pipeline, running health checks and
18+ /// ensuring it is reachable for this e2e tests.
19+ /// </para>
20+ /// </remarks>
21+ public void Launch ( )
22+ {
23+ var pathToBackend = Path . GetFullPath (
24+ Path . Combine (
25+ Environment . CurrentDirectory ,
26+ ".." ,
27+ ".." ,
28+ ".." ,
29+ ".." ,
30+ "Backend" ,
31+ "Backend" ,
32+ "Backend.csproj" ) ) ;
33+
34+ var startInfo = new ProcessStartInfo
35+ {
36+ FileName = "dotnet" ,
37+ Arguments =
38+ $ "run --project { pathToBackend } --applicationUrl http://localhost:5045",
39+ RedirectStandardOutput = true ,
40+ RedirectStandardError = true ,
41+ UseShellExecute = false ,
42+ CreateNoWindow = true
43+ } ;
44+ process = Process . Start ( startInfo ) ;
45+ }
46+
47+ public void Dispose ( )
48+ {
49+ process . Kill ( ) ;
50+ }
51+ }
You can’t perform that action at this time.
0 commit comments