Skip to content

Commit

Permalink
added after test cleanup to config unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonreding2010 committed Mar 2, 2023
1 parent 807489b commit 827f5a0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;

/**
Expand All @@ -27,17 +27,25 @@
public class LoggerFactoryUnitTest {

/**
* Test getting the logger.
* Revert the config back to what it was before.
*/
@Test(groups = TestCategories.UTILITIES)
public void testGetLogger() {
@AfterMethod
private void cleanUp() {
HashMap<String, String> newValueMap = new HashMap<>();
newValueMap.put("Log", "OnFail");
newValueMap.put("LogLevel", "VERBOSE");
newValueMap.put("LogType", "TXT");
Config.addGeneralTestSettingValues(newValueMap, true);
}

/**
* Test getting the logger.
*/
@Test(groups = TestCategories.UTILITIES)
public void testGetLogger() {
Assert.assertNotNull(LoggerFactory.getLogger("Test Name"));

newValueMap = new HashMap<>();
HashMap<String, String> newValueMap = new HashMap<>();
newValueMap.put("Log", "NO");
newValueMap.put("LogType", "TXT");
Config.addGeneralTestSettingValues(newValueMap, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.io.File;
import java.util.HashMap;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;

/**
Expand All @@ -27,6 +28,18 @@
@Test(singleThreaded = true)
public class LoggingConfigUnitTest {

/**
* Revert the config back to what it was before.
*/
@AfterMethod
private void cleanUp() {
HashMap<String, String> newValueMap = new HashMap<>();
newValueMap.put("Log", "OnFail");
newValueMap.put("LogLevel", "VERBOSE");
newValueMap.put("LogType", "TXT");
Config.addGeneralTestSettingValues(newValueMap, true);
}

/**
* Test getting Logging Enabled Setting. Override Config to 'YES'
*/
Expand Down Expand Up @@ -73,10 +86,6 @@ public void getCreateLogInvalidArgumentTest() {
newValueMap.put("Log", "INVALIDVALUE");
Config.addGeneralTestSettingValues(newValueMap, true);
LoggingConfig.getLoggingEnabledSetting();

newValueMap.clear();
newValueMap.put("Log", "OnFail");
Config.addGeneralTestSettingValues(newValueMap, true);
}

/**
Expand Down Expand Up @@ -185,10 +194,6 @@ public void getLoggingLevelInvalidArgumentTest() {
newValueMap.put("LogLevel", "INVALIDVALUE");
Config.addGeneralTestSettingValues(newValueMap, true);
LoggingConfig.getLoggingLevelSetting();

newValueMap.clear();
newValueMap.put("LogLevel", "OnFail");
Config.addGeneralTestSettingValues(newValueMap, true);
}

/**
Expand Down

0 comments on commit 827f5a0

Please sign in to comment.