Getting saved 0 shards error when sending espresso test suite class to firebase - ui-automation

when I send my test classes one by one to firebase with the same method, I don't get an error, but when I export test suite to target, i am getting this error "There are no Android tests to run.". Could it be a problem caused by annotations? I'll be glad if you can help me.
Here is my test suite class :
import org.junit.runner.RunWith
import org.junit.runners.Suite
#RunWith(Suite::class)
#Suite.SuiteClasses(
SampleScreenTest::class,
ExampleScreenTest::class,
SampleListScreenTest::class
)
class TestSuite
This is how I added it to Gradle:
perfTests {
devices.set([
[ "model": "NexusLowRes", "version": "23" ]
])
testTargets.set([
"class com.sample.utils.TestSuite"
])
}
This is how I triggered in terminal
./gradlew runFlankperfTests

Related

How to configure with gradle running JUnit4 tests with categories using vintage engine of jupiter Junit5 platform

When we had only JUnit4 tests, we used
test {
useJUnit{
excludeCategories "SlowTests"
}
}
Now migrating to JUnit5 and still having JUnit4 tests around, how do we use it in JUnitPlattform to let tests marked with a JUnit test category out?
test {
useJUnitPlatform{
// ???
}
}
JUnit4's categories are mapped to tags according to the full class name of the category
So the following should work:
tasks.test {
useJUnitPlatform {
includeTags.add("com.acme.Example")
// or the following to exclude the tag: includeTags.add("!com.acme.Example")
}
}

DotMemory error (comparing snapshot to itself)

Attempting to do some memory leak checks in my automation test using the following
nUnit 3.8.1
TestStack.White 0.13.3
dotMemory 3.0.20171219.105559
Launching my tests with the following console command, as outlined here.
dotMemoryUnit.exe "E:\nunit3-console.exe" -- "C:\Dev\White\bin\Debug\Automation.dll"
The tests (outlined below in mostly psuedocode) launches the application, grabs a snapshot, navigates into various sub pages, returns to the base page, adn then gets another snapshot so I can do a compare for survived objects. The snapshot comparison is done using the method outlined here
private const MemoryCheckPoint snapshot1
[ OneTimeSetUp ]
public void SetUp()
{
// launch application, hook up with teststack.white
LaunchApplication();
}
[ Test, Order(1) ]
public void GetSnapshot()
{
snapshot1 = dotMemory.Check();
}
[ Test, Order(2) ]
public void DoStuff()
{
//Many tests like this that test navigation from this page
//making sure controls work and values are returned as expected
}
[ Test, Order (3) ]
public void CheckMemory()
{
dotMemory.Check(memory =>
{
// Compare two checkpoints
Assert.That(memory.GetDifference(snapshot1).GetSurvivedObjects
(where => where.Type.Is<string>()).ObjectsCount, Is.EqualTo(0));
});
}
[ OneTimeTearDown ]
public void CloseWindow()
{
Application.Close();
}
The idea is that if there are any UI elements that don't get disposed of due to events etc, this should pick them up as survived objects, and then I can manually repeat the test later to track down the source of the problem.
However when I run the tests using the dotmemoryunit.exe console I get the following error.
1) Error : White.Tests.MemoryCheck.System.ArguementException : You are trying to compare the snapshot with itself at JetBrains.dotMemoryUnit.Kernel.dotMemory.Api.GetDifference< Snapshot snapshot1, Snapshot snapshot2>
Considering they're definitely different snapshots, I cannot figure out why this is failing.
The reason I'm using the console runner is because, for some reason, when I try to run the automation tests using the resharper test runner, they don't run and it just returns Inconclusive : test not run
By default dotMemory Unit works in context of the "Test", you can think about it like at the very beginning of the test method there is a call DotMemoryUnitController.TestStart and at the very end DotMemoryUnitController.TestEnd. All data are only valid inside one "Test".
You can switch off this behaviour by specifying --no-instrumentation command line parameter and calling DotMemoryUnitController.TestStart and DotMemoryUnitController.TestEnd manualy how described in this article

Embedding multiple tests inside an akka-http route check

I'm using akka-http for the first time - my usual web framework of choice is http4s - and I'm having trouble getting the way I usually write endpoint unit tests to work with the route testing provided by akka-http-testkit.
Generally, I use ScalaTest (FreeSpec flavour) in order to set up an endpoint call and then run several separate tests on the response. For akka-http-testkit, this would look like:
import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.Route
import akka.http.scaladsl.testkit.ScalatestRouteTest
import org.scalatest.{FreeSpec, Matchers}
final class Test extends FreeSpec with ScalatestRouteTest with Matchers {
val route: Route = path("hello") {
get {
complete("world")
}
}
"A GET request to the hello endpoint" - {
Get("/hello") ~> route ~> check {
"should return status 200" in {
status should be(StatusCodes.OK)
}
"should return a response body of 'world'" in {
responseAs[String] should be("world")
}
//more tests go here
}
}
}
This errors with
java.lang.RuntimeException: This value is only available inside of a `check` construct!
The problem is the nested tests inside the check block - for some reason, values like status and responseAs are only available top-level within that block. I can avoid the error by saving the values I'm interested in to local variables top-level, but that's awkward and capable of crashing the test framework if e.g. the response parsing fails.
Is there a way around this, without putting all my assertions into a single test or performing a new request for each one?
You can group your test like that
"A GET request to the hello endpoint should" in {
Get("/hello") ~> route ~> check {
status should be(StatusCodes.OK)
responseAs[String] should be("world")
//more tests go here
}
}

When I run tests with scalaTestPlus and Play framework, I get an error "no started application"

I'm trying to make scalaTestPlus work in my play application (I'm using Play! 2.2). It works well until I need a function coming from my application. For instance, if I run this very simple test (by launching in a sbt console "test-only TestName"):
import org.scalatestplus.play._
import org.scalatest._
import Matchers._
class Test extends PlaySpec {
"This test" must {
"run this very simple test without problem" in {
1 mustEqual 1
}
}
}
There is no problem, but as soon as I call a function from my app, like in this code:
class Test extends PlaySpec {
"This test" must {
"run this very simple test without problem" in {
models.Genre.genresStringToGenresSet(Option("test")) //Here is the problem
1 mustEqual 1
}
}
}
I get an error: java.lang.ExceptionInInitializerError: at... Cause: java.lang.RuntimeException: There is no started application (even if my application is running).
I'm probably missing something simple since I'm brand new to ScalaTest, so any help abut what I'm doing wrong would be apreciated ;)
You may need an application in scope when using PlaySpec, as some operations assume that there is a Play application available via Play.current:
class Test extends PlaySpec {
implicit override lazy val app: FakeApplication = FakeApplication(...)
"This test" must {
"run this very simple test without problem" in {
models.Genre.genresStringToGenresSet(Option("test")) //Here is the problem
1 mustEqual 1
}
}
}
Check the functional testing documentation for more details on FakeApplication.
However, I don't think you need should need this for model testing. In the normal ScalaTest docs for play, it seems to just mix inMockitoSugar. But your method call chain may invoke some global state of Play that does require an Application, in which case the FakeApplication is the way to go
As asked by #akauppi, here is a method that works perfectly for me:
import org.scalatestplus.play.{OneAppPerSuite, PlaySpec}
class A extends PlaySpec with OneAppPerSuite {
"a" must {
"return true" in {
//thanks to with OneAppPerSuite, it now works
models.Genre.genresStringToGenresSet(Option("test"))
1 mustBe 1
}
"return false" in {
1 mustBe 2
}
}
}
And I simply launch the test with sbt ~testOnly a

No JUnit tests found in Eclipse using Groovy + Cucumber

I have a Cucumber test in Groovy as follows
import org.junit.runner.RunWith
import cucumber.junit.Cucumber
import cucumber.junit.Cucumber.Options
#RunWith(Cucumber.class)
#Options(features = ["classpath:CarDrive.feature"])
public class FuelCarTest {
}
import cucumber.annotation.en.Given
import cucumber.annotation.en.Then
import cucumber.annotation.en.When
public class FuelCarSteps {
public FuelCarSteps() {
println "FuelCarSteps::FuelCarSteps"
}
#Given("I have a car")
def givenCar() {
println "I have a car"
}
#When("^you fill it with 50 litres of fuel")
def addFuel() {
println "add fuel"
}
#Then("^the tank contains 60 litres")
def checkBalance() {
println "TODO: add check here"
}
}
I can run the test fine using mvn test, but when I try to run it in Eclipse I get
No JUnit tests found
Tried cleaning, rebuilding & restarting
Hi you need to create run configuration for the each test in junit
Provide full path ( like package1.subpackege1.testclassname ) in class input in run config
Control, if you have any errors in the Groovy code, such as Type of expression is statically unknown: or similar. They don't show off as usual errors and could be almost invisible.