I'm writing UI tests in Xamarin UITest and when I run several tests behind the app never really is in a "clean" state. So when test A is executed and it is on screen y, test B will start and the app will be on screen y. Also some configurations are also present.
I tried to set the AppDataMode to clear in the AppInitializer.cs but this has no effect at all. On Android this problem does not occure. Tips and suggestions are more then welcome!
Thanks in advance
Apparently this is a known issue and the solution will be to force the ios simulator
public class AppInitializer
{
public static IApp StartApp(Platform platform)
{
if (platform == Platform.Android)
{
return ConfigureApp.Android.StartApp();
}
Environment.SetEnvironmentVariable("UITEST_FORCE_IOS_SIM_RESTART", "1"); // <---- Add this line
return ConfigureApp.iOS.StartApp();
}
}
According to JGoldbverger from Xamarin. Source => https://forums.xamarin.com/discussion/149966/xamarin-uitest-does-not-clean-my-app-on-ios/.
Related
I'm using Mac OS Catalina (10.15.3) Here is my code.
dart shows an error Only static members can be accessed in initializers
And that's it. Error doesn't go away. Even when comment everything delete everything dart continues giving that error. I don't understand. Was working in Android Studio. Exactly the same. I thought it was Android Studio problem. Because of that I downloaded VS Code but again. Here is the photo of error after I comment lines.
Please help me. It annoys me. I don't know what to do.
Edit 1:
I could reproduce the issue.
Let's say I have some StateLessWidget class
class SearchPage extends StatelessWidget {
// Whenever I try to write property beginning with type Future
Future<... // <--- Android Studio and VS Code both stop working.
// then it starts working when I restart
#override
Widget build(BuildContext context) {
return Container();
}
}
Then doesn't matter what you do. Nothing works until restart.
Here's a few things you can try :
Update VS Code.
Does flutter doctor -v contains any error message ?
Try running flutter clean
Open pubspec.yaml, right-click and "Get Packages".
Move to another channel (flutter channel beta for example) and run
flutter upgrade
Delete and reinstall Flutter and its IDE extensions
I'm using the javafx-maven-plugin and IntelliJ IDEA on Windows 7.
I'm trying to get a splash screen to show while my JavaFX application boots up, like this:
I tried using the SplashScreen-Image manifest entry—and that works, but only if you click on the .jar—I'm deploying the application as a Native Bundle and so the user clicks an .exe (or a shortcut to an .exe) not the actual .jar.
When you click the .exe no splash screen is shown.
This SSCCE I made will help you help me.
If I'm deploying my app using the javafx-maven-plugin, (which, if I'm not mistaken, uses the JavaFX Packager Tool, which uses Inno Setup), how can I get a splash screen to show after the user clicks the .exe?
More Findings:
Looking at the installation directory, I find a .dll called runtime\bin\splashscreen.dll. Does that mean it can be done?
The native launcher does not respect that spash-screen, it is only when being invoked by the java-executable. As the native launcher is loading the JVM internally, this won't work.
I haven't found a proper way to get this working, not even with some preloaders. Maybe you can find this helpful: https://gist.github.com/FibreFoX/294012b16fa10519674b (please ignore the deltaspike-related stuff)
Copied code:
#Override
public void start(Stage primaryStage) throws Exception {
// due to the nature of preloader being ignored within native-package, show it here
SplashScreen splashScreen = new SplashScreen();
splashScreen.show(new Stage(StageStyle.TRANSPARENT));
// needed for callback
final SomeJavaFXClassWithCDI launcherThread = this;
// for splashscreen to be shown, its needed to delay everything else as parallel task/thread (it would block otherwise)
Task cdiTask = new Task<Void>() {
#Override
protected Void call() throws Exception {
// boot CDI after javaFX-splash (this will "halt" the application due to the work done by CDI-provider
bootCDI(launcherThread);
// push javaFX-work to javaFX-thread
Platform.runLater(() -> {
primaryStage.setTitle("Some Title");
// TODO prepare your stage here !
// smooth fade-out of slashscreen
splashScreen.fadeOut((ActionEvent event) -> {
primaryStage.show();
splashScreen.hide();
});
});
return null;
}
};
// run task
new Thread(cdiTask).start();
}
In short: I'm creating my splashscreen myself.
Disclaimer: I'm the maintainer of the javafx-maven-plugin
We are doing investigation for the Test Clouds for our Android and IOS apps. I made a test snippet which installs and launches the android app. And then takes the screenshot. I am using Visual Studio to write the tests. And Visual Studio emulator to run the android app and xamarin test. Xamarin test is able to install the app, but then throws the error. Code and Errors can be found below.
Other observations:
I am using Test account for my investigations which is free for 30 days.
But I don't see my computer added in the link: https://store.xamarin.com/account/my/subscription/computers. While, I have logged in from Visual Studio in my PC.
Due to this I can't copy the license file too. Can that be the reason? If yes, what is the best way to investigate this without getting full subscription.
Code:
[TestFixture]
public class Tests
{
AndroidApp app;
[SetUp]
public void BeforeEachTest()
{
// TODO: If the Android app being tested is included in the solution then open
// the Unit Tests window, right click Test Apps, select Add App Project
// and select the app projects that should be tested.
app = ConfigureApp
.Android
// TODO: Update this path to point to your Android app and uncomment the
// code if the app is not included in the solution.
.ApkFile(#"C:\MobileOnly\SampleProjects\AndroidSampleProjects\InfraTest\app\build\outputs\apk\app-debug.apk")
// .InstalledApp("com.microsoft.mobile.infratest")
.StartApp(Xamarin.UITest.Configuration.AppDataMode.Clear);
}
[Test]
public void AppLaunches()
{
app.Screenshot("First screen.");
}
}
Error:
Test Name: AppLaunches
Test FullName: XamarinUITest.Tests.AppLaunches
Test Source: : line 0
Test Outcome: Failed
Test Duration: 0:00:11.233
Result StackTrace:
at Xamarin.UITest.Shared.Processes.ProcessRunner.Run(String path, String arguments)
at Xamarin.UITest.Shared.Android.Commands.CommandAdbInstallPackage.Execute(IProcessRunner processRunner, IAndroidSdkTools androidSdkTools)
at Xamarin.UITest.Shared.Android.LocalAndroidAppLifeCycle.InstallApps(ApkFile[] apkFiles)
at Xamarin.UITest.Shared.Android.LocalAndroidAppLifeCycle.EnsureInstalled(ApkFile appApkFile, ApkFile testServerApkFile)
at Xamarin.UITest.Android.AndroidApp..ctor(IAndroidAppConfiguration appConfiguration)
at Xamarin.UITest.Configuration.AndroidAppConfigurator.StartApp(AppDataMode appDataMode)
at XamarinUITest.Tests.BeforeEachTest() in C:\MobileOnly\SampleProjects\AndroidSampleProjects\XamarinUITest\XamarinUITest\Tests.cs:line 22
Result Message:
SetUp : System.Exception : Failed to execute: C:\NugetCache\androidsdk.23.0.4\platform-tools\adb.exe -s 169.254.138.177:5555 install "C:\Users\gunjansa\AppData\Local\Temp\uitest\a-6EAAB1A4CD21F05DB755FBC781EAD620D4ADACBC\final-D9BA1DA5963F9B7853DABC6DEC56BFF2F4740ADE.apk" - exit code: -1073740940
WARNING: linker: libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
pkg: /data/local/tmp/final-D9BA1DA5963F9B7853DABC6DEC56BFF2F4740ADE.apk
Update the Xamarin.UITest NuGet and try
public void BeforeEachTest()
{
// TODO: If the Android app being tested is included in the solution then open
// the Unit Tests window, right click Test Apps, select Add App Project
// and select the app projects that should be tested.
app = ConfigureApp
.Android
.StartApp();
}
I would do below actions
Restore your UITest project packages
Make sure that you dont see any app named with the package id though the app is completely uninstalled from the device. Often this is the case where uitests uninstalls the existing version of the app and leaves the folders behind causing this issue.
Hope this resolves your issue.
In the prior test flight system we pushed AdHoc builds which we used a compiler constant to identify to turn on/off features for our beta testers. Now with Apple's Beta Test Flight System we have to build for the App Store, i.e. not AdHoc, which is fine as if it tests good we can use the same build for a production review.
Is there any way from within iOS to detect that the build is a Test Flight delivered build so we know "this is beta" and do the same as before with the AdHoc compiler constant?
Thank you
There is one way that I use it for my projects.
In Xcode, go to the the project settings (project, not target) and add "beta" configuration to the list:
Then you need to create new scheme that will run project in "beta" configuration. To create scheme go here:
Name this scheme whatever you want. The you should edit settings for this scheme. To do this, tap here:
Select Archive tab where you can select Build configuration
Then you need to add a key Config with value $(CONFIGURATION) the projects info property list like this:
Then its just the matter what you need in code to do something specific to beta build:
let config = Bundle.main.object(forInfoDictionaryKey: "Config") as! String
if config == "Debug" {
// app running in debug configuration
}
else if config == "Release" {
// app running in release configuration
}
else if config == "Beta" {
// app running in beta configuration
}
Here's a simple and useful function you can use in any app to easily check if the running app was installed by TestFlight:
func isTestFlight() -> Bool {
guard let path = Bundle.main.appStoreReceiptURL?.path else {
return false
}
return path.contains("sandboxReceipt")
}
No need to create special build configs, schemes, etc.
Xamarin Noob
Xamarin.Forms Noob
I am all hooked up. Business license on iOS and Android and developing from VS 2013.
I created the initial sample from the Xamarin Intro to Forms.
I 'Start'ed the app and it ran fine on my Mac. I saw the 'Hello, Forms !' label in the running app in the iOS simulator on my Mac Build Machine.
I then replaced the following code in my App.cs
public static Page GetMainPage()
{
return new ContentPage
{
Content = new Label
{
Text = "Hello, Forms !",
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.CenterAndExpand,
},
};
}
with:
public static Page GetMainPage()
{
return new ContentPage()
{
Content = new StackLayout
{
Spacing = 10,
Children =
{
new Label
{
Text = "Stop",
BackgroundColor = Color.Red,
Font = Font.SystemFontOfSize(20)
},
new Label
{
Text = "Slow down",
BackgroundColor = Color.Yellow,
Font = Font.SystemFontOfSize(20)
},
new Label
{
Text = "Go",
BackgroundColor = Color.Green,
Font = Font.SystemFontOfSize(20)
}
}
}
};
}
That's all I did, but now the app will not run in the simulator - it always exists as soon as it starts...
I put the original code back again, and it still doesn't start.
I always see (in My VS 12013 Mac Server Log)
[10-Nov-2014 15:43:32] Request handled in 4.129ms
[10-Nov-2014 15:43:37] Request handled in 3.728ms
[10-Nov-2014 15:43:40] stdout: Starting iPhone 5s
Launching application
Application launched. PID = 2872
Press enter to terminate the application
>
Application Terminated
[10-Nov-2014 15:43:42] Request handled in 3.898ms
[10-Nov-2014 15:43:48] Request handled in 4.031ms
etc....
I have exited both the iOS simulator and VS 2013, paired them again, all to no avail...
What could possibly be wrong?
EDIT
Infact, when the app becomes visible in the simulators view of icons, clicking it brings up the original version of "Hello, Forms!" - so my new code is never deployed to the simulator...
EDIT 2
Ok, I got the new content moving and got it running:
I had to manually "Reset content on device" in the iOS simulator on the Mac.
I also had to manually clean each project in VS 2013 - just rebuilding the solution doesn't do anything to the content being sent to the Mac iOS simulator server, I guess.
I hope this helps someone as new as I am.
Try removing "." from your app's name in Info.plist file.
After fiddling..
The way to fix this is to change the build config on the solution.
In a fresh Xamarin.Forms solution in Visual Studio, you might have:
Solution 'MyXFormsSample' (3 projects)
v MyXFormsSample (Portable)
> Properties
> References
> App.cs
packages.config
> MyXFormsSample.Android
> MyXFormsSample.iOS
It seems that by default, in the solution's Configuration Manager's build configuration, the portable code project is not set to build for the iPhoneSimulator platform
I clicked that on for the debug, and also release, solution configurations, and still I had to Reset Content on the Mac's iOS simulator before debugging, then all I had to do was press the green 'Start' button in the menu - all was updated and released to the Mac Build server's iOS Simulator.