Run XCTest in a project created with react-native - xcode

I am trying to run XCTest on a project created with react-native.
import XCTest
import React
final class ImageProcessing: XCTestCase {
override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
func testExample() throws {
XCTAssert(1 == 1)
}
func testPerformanceExample() throws {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}
}
I get en error when running the test
Expo modules provider must implement `ModulesProviderProtocol`.
I am not even using Expo in the react-native app.

Related

Quarkus #CacheResult is not working properly

I am trying to use quarkus-cache by following the appropriate quarkus doc. I have the below code setup
#ApplicationScoped
class MyClass {
public result doSomething() {
String remoteData = getRemoteData(url);
}
#CacheResult(cacheName = "myCacheName")
public String getRemoteData(String url) {
return remoteCall(url);
}
}
Usage
// Grpc impl class
// call to Myclass.doSomething()
Execution is not proceeding further when getRemoteData() is called the first time. Also, not getting any error.
Am I missing something?

How can I use an externally created singleton to satisfly a dependency in Spring?

Let's say I have a configuration like this:
#Configuration
open class AppConfig {
#Bean
open fun mainWindow(stage: Stage): MainWindow {
return MainWindow(stage)
}
}
I also have a class where my app gets initialized. I'm using JavaFX, so I can't create the stage myself, instead it gets passed in to a function.
class MyApplication : Application()
{
override fun start(stage: Stage)
{
// I can't create the stage myself.
val ctx = AnnotationConfigApplicationContext(AppConfig::class.java)
ctx.beanFactory.registerSingleton("stage", stage)
stage.run {
scene = Scene(mainWindow, 800.0, 600.0)
show()
}
}
}
I get an error in the configuration class that "Could not autowire. No beans of 'Stage' type found"
What can I do so that the stage I registered could be used to satisfy Stage dependencies?

Kotest and kotlinx-coroutines-test Integration

I use the Funspec testing style in kotest and I get a coroutineScope injected automatically by the framework as shown below.
class MyTestSpec: FunSpec() {
init {
test("test event loop") {
mySuspendedFunction() // a coroutineScope is already injected by the test framework here
}
}
}
How can I configure the Kotest framework to use an instance of kotlinx.coroutines.test.TestCoroutineScope instead of a kotlinx.coroutines.CoroutineScope in my tests? or is there a reason why this wouldn't make sense?
Since Kotest 5.0, there is built-in support for TestCoroutineDispatcher. See here
Simply:
class MyTest : FunSpec(
{
test("do your thing").config(testCoroutineDispatcher = true) {
}
}
)
Create a test listener like this:
class MainCoroutineListener(
val testDispatcher: TestCoroutineDispatcher = TestCoroutineDispatcher()
) : TestListener {
override suspend fun beforeSpec(spec: Spec) {
Dispatchers.setMain(testDispatcher)
}
override suspend fun afterSpec(spec: Spec) {
Dispatchers.resetMain()
testDispatcher.cleanupTestCoroutines()
}
}
Then use it in your test like this
class MyTest : FunSpec({
listeners(MainCoroutineListener())
tests...
})

Spring Boot Cucumber Java 8 Testing ApplicationOnReady Event

I have a reporting application that generates a report on ApplicationReadyEvent. I am trying to write cucumber tests for it but as the application event is fired even before my feature is executed , i am not sure what is the right way to test it. Can i control the event during testing ?
#EventListener(ApplicationReadyEvent.class)
private void generateAccuracyAnalysisReport() throws IOException
{
//some Logic
}
Cucumber Classes :
#SpringBootTest
#CucumberContextConfiguration
#ActiveProfiles("junit")
public class CucumberConfiguration
{
}
#RunWith(Cucumber.class)
#CucumberOptions(plugin = "pretty", features = "src/test/resources/cucumber/features")
public class CucumberFullIntegrationTest
{
}
Step Definition:
public class ReportStepDefs implements En {
public ReportStepDefs() {
When("^System sends an application event to generate report$", () -> {
});
Then("^Report should be generated successfully\\.$", () -> {
});
}
}
If your Cucumber tests involve Spring life-cycle you can not use cucumber-spring. Rather you have to use something like Springs ApplicationContextRunner to, configure, run and verify something about your application as part of each scenario.
// Given
ApplicationContextRunner contextRunner = new ApplicationContextRunner();
// When
contextRunner.withConfiguration(AutoConfigurations.of(...);
// Then
contextRunner.run(context -> assertThat(context).... /* something */ );
// Or assert something external to the application context.
Though it sounds like your application is doing something once and then exits. If so you should be using the CommandLineRunner instead of ApplicationReadyEvent in a web application. This is testable with cucumber-spring.
#RequiredArsConstructor
public class StepDefinitions {
final MyCommandLineRunner commandLineRunner;
#When(....)
public void something() {
commandLineRunner.run("input.txt", "input2.txt");
}
#Then(....)
public void assertSomething() {
// check if report was generated
}
}

Resolution failed exception in Xamarin IOS prism

I have an iOS application written in Xamarin and I am getting a Unity Exceptions Resolution Failed exception when I try and run the application in iOS. However this error does not happen when I run the android version of the application. The exception is being thrown while the initalize function from prism is taking place.
Here is a snippet from my app.xaml.cs
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
this.RegisterLocal(containerRegistry);
this.RegisterServices(containerRegistry);
this.RegisterPagesForNavigation(containerRegistry);
}
This code all executes and passes.
This is the iOS initialization
Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
PullToRefreshLayoutRenderer.Init();
LoadApplication(new App(new IosInitializer()));
return base.FinishedLaunching(app, options);
}
public class IosInitializer : IPlatformInitializer
{
public void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry.Register<IUAirshipUpdate, UAirshipUpdate>();
}
}
This code also executes
The exception being thrown is an argument null exception indicating that IModuleCatelog is not present. I do not understand why it is looking for that module and can not find it. The source code on GitHub indicates that class was registered.
This issue was caused because linker behavior for IOS application was set to full and that causes issues with Unity IOC Container.

Resources