Skip to content

Commit

Permalink
fixing flaky tests (#109)
Browse files Browse the repository at this point in the history
* fixing flaky tests

* addressing comments
  • Loading branch information
prklm10 authored Sep 26, 2023
1 parent 8502cea commit 580e256
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 22 deletions.
12 changes: 3 additions & 9 deletions Percy.Tests/AppPercyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public class AppPercyTest

public AppPercyTest()
{
AppPercy.cache.Clear();
TestHelper.UnsetEnvVariables();
Environment.SetEnvironmentVariable("PERCY_DISABLE_REMOTE_UPLOADS", "true");
mockDriver = new MockDriverObject();
mockDriver.SessionId = "session-1";
CliWrapper.Healthcheck = () =>
Expand Down Expand Up @@ -47,8 +50,6 @@ private static String LogMessage(String label, String message, String color = "3
public void TestName_WithAndroid_V4()
{
// Arrange
AppPercy.cache.Clear();
TestHelper.UnsetEnvVariables();
mockDriver.SetCapability(MetadataBuilder.CapabilityBuilder("Android"));
mockDriver.setCommandExecutor("https://browserstack.com/wd/hub");
// Act
Expand All @@ -66,7 +67,6 @@ public void TestName_WithAndroid_V4()
public void TestName_WithIOS_V4()
{
// Arrange
AppPercy.cache.Clear();
mockDriver.SetCapability(MetadataBuilder.CapabilityBuilder("iOS"));
mockDriver.setCommandExecutor("https://browserstack.com/wd/hub");

Expand All @@ -85,8 +85,6 @@ public void TestName_WithIOS_V4()
public void TestName_WithAndroid_V5()
{
// Arrange
AppPercy.cache.Clear();
TestHelper.UnsetEnvVariables();
// Setting v5
mockDriver.setIsV5(true);
mockDriver.SetCapability(MetadataBuilder.CapabilityBuilder("Android"));
Expand All @@ -107,8 +105,6 @@ public void TestName_WithAndroid_V5()
public void TestName_WithIOS_V5()
{
// Arrange
AppPercy.cache.Clear();
TestHelper.UnsetEnvVariables();
// Setting v5
mockDriver.setIsV5(true);
mockDriver.SetCapability(MetadataBuilder.CapabilityBuilder("iOS"));
Expand All @@ -129,8 +125,6 @@ public void TestName_WithIOS_V5()
public void TestName_ShouldThrowError()
{
// Arrange
AppPercy.cache.Clear();
TestHelper.UnsetEnvVariables();
// Setting v5
mockDriver.setIsV5(true);
mockDriver.SetCapability(MetadataBuilder.CapabilityBuilder("iOS"));
Expand Down
11 changes: 0 additions & 11 deletions Percy.Tests/PercyOnAutomateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,6 @@ public PercyOnAutomateTest()
{
return true;
};
mockHttp = new MockHttpMessageHandler();
var obj = new
{
success = true,
type = "automate"
};
CliWrapper.setHttpClient(new HttpClient(mockHttp));
// Setup a respond for the user api (including a wildcard in the URL)
mockHttp.When("http://localhost:5338/percy/healthcheck")
.Respond("application/json", JsonConvert.SerializeObject(obj));

stringWriter = new StringWriter();
Console.SetOut(stringWriter);
}
Expand Down
4 changes: 2 additions & 2 deletions Percy.Tests/helper/MockDriverObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void SetCapability(Dictionary<string, object> caps)
}
},
{
"pixelRatio", 1
"pixelRatio", 1l
}
};
}
Expand Down Expand Up @@ -69,7 +69,7 @@ public Object GetScreenshot()
return new Screenshot();
}

public Object ExecuteScript(String script, Object obj)
public Object ExecuteScript(String script)
{
return @"{success:'true', osVersion:'11.2', buildHash:'abc', sessionHash:'def'}";
}
Expand Down

0 comments on commit 580e256

Please sign in to comment.