Maven to First Test Case Execution
Complete execution path from mvn verify to first test case
Overview
This diagram traces the complete execution path from running mvn verify in the terminal through to the execution of the first test case in the SwagLabs test suite. Understanding this flow is essential for debugging test startup issues and configuring test execution.
Execution Flow Stages
- Maven Initialization: Command processing and phase execution
- Test Framework Setup: JUnit and Surefire plugin initialization
- Test Suite Configuration: BeforeAll hooks and configuration loading
- Test Case Preparation: BeforeEach hooks and resource setup
- Test Execution: First test case runs with initialized resources
Detailed Flow Diagram
graph TB
subgraph Terminal["Terminal Command"]
T1[Run Command: mvn verify]
end
T1 --> M1[Maven]
subgraph Maven["Maven Build Lifecycle"]
M1[Maven Initialization]
M1 --> M2[Validate Phase]
M2 --> M3[Compile Phase]
M3 --> M4[Test Phase]
M4 --> M5[Surefire Plugin Execution]
M5 --> M6[Test Discovery & Execution]
end
M6 --> TS1[TS_SwagLabs_JUnit Execution]
subgraph TS_SwagLabs_JUnit["Test Suite: TS_SwagLabs_JUnit"]
TS1 --> TS2a[BeforeAll: setupTestSuite]
subgraph BeforeAll["@BeforeAll Hook"]
TS2a[Create anonymous object and get class name]
TS2a --> TS2b[Call FW_TestSuiteFormatter.beforeAll with class name]
TS2b --> TS2c[Load testConfig.properties]
end
TS2c --> TS3a[BeforeEach: setupTestCase]
subgraph BeforeEach["@BeforeEach Hook - Current Pattern"]
TS3a[Call FW_TestSuiteFormatter.beforeEach with testInfo]
TS3a --> TS3e[Create WebDriver Instance]
TS3e --> TS3f[Instantiate Page Objects<br/>Login, Products, Cart, etc.]
end
TS3f --> TS4[First Test Case:<br/>TC - SwagLabs - Missing Username and Password]
end
subgraph FW_TestSuiteFormatter["Framework Component: FW_TestSuiteFormatter"]
TS2b <--> TSF1[beforeAll Method]
TSF1 --> TSF2[Get Suites, Cases & Steps totals]
TSF2 --> TSF3[Print test details to terminal]
TS3a <--> TSF4[beforeEach Method]
end
subgraph FW_TestRunTracker["Framework Component: FW_TestRunTracker"]
TSF1 <--> TRT1[getInstance:<br/>FW_TestRunTracker singleton]
end
subgraph FW_ConfigMgr["Framework Component: FW_ConfigMgr"]
TS2c <--> CM1[getInstance:<br/>FW_ConfigMgr singleton]
end
Key Components
Maven Phases
| Phase | Description |
|---|---|
validate | Validates project structure |
compile | Compiles source code |
test | Runs unit tests via Surefire |
verify | Runs integration tests |
Framework Initialization
- FW_TestSuiteFormatter: Formats and tracks test execution
- FW_TestRunTracker: Singleton tracking test run metrics
- FW_ConfigMgr: Manages test configuration properties
- WebDriver: Browser automation driver instance
- Page Objects: Encapsulated page element interactions
Configuration Files
pom.xml- Maven configuration and dependenciestestConfig.properties- Test execution parameters- Test data files and schemas
Pattern Evolution
Current Pattern (v1.2.0)
The @BeforeEach hook now follows a simplified pattern:
- Call FW_TestSuiteFormatter.beforeEach for test tracking
- Create WebDriver instance for browser automation
- Instantiate Page Objects for test interactions
Deprecated Components (Removed)
Previous versions included these components in @BeforeEach:
FW_Audit_Connectivity- Network connectivity validation (deprecated)FW_Audit_Sandbox- Environment validation (deprecated)
These audit functions are now handled through dedicated audit test suites (TS_HttpAssessment_JUnit, TS_Network_JUnit), pre-test environment validation in Maven lifecycle, and framework-level health checks in FW_AuditManager.
Related Documentation
| Document | Description |
|---|---|
| Architecture Overview | Framework layers |
| Test Development Guide | Writing tests |
| Test Execution in VSCode | IDE execution |
| Data Collection Flow | Data pipeline |
| HTTP Assessment | HTTP audit details |
| Network Diagnostics | Network audit details |