-
Notifications
You must be signed in to change notification settings - Fork 53.5k
Expand file tree
/
Copy pathNameByResultTest.java
More file actions
27 lines (22 loc) · 868 Bytes
/
Copy pathNameByResultTest.java
File metadata and controls
27 lines (22 loc) · 868 Bytes
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
package com.baeldung.testng;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.ITestResult;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class NameByResultTest {
private static final Logger logger = LoggerFactory.getLogger(NameByResultTest.class);
private String testName;
@BeforeMethod
public void capture(ITestResult result) {
String testName = result.getMethod().getMethodName();
this.testName = testName;
logger.info("Starting test {}", testName);
}
@Test
public void givenTestNameSetup_WhenTestNameIsRequested_ThenShouldReturnTestName() {
logger.info("Executing scenario {}", testName);
Assert.assertEquals(testName, "givenTestNameSetup_WhenTestNameIsRequested_ThenShouldReturnTestName");
}
}