Dart unit test not working with content-shell - dart

I have dart unit tests written using test: '>=0.12.1 <0.13.0' library. When I try to run tests using Dartium it works perfectly, but using content-shell it throws error.
pub run test test/unit -p content-shell
Failed to start content shell: Bad state: Stream has already been listened to..
I'm using ubuntu machine and content shell is in path.

I upgraded the dart and content-shell version to 1.11 and its working now.

Related

how to create dart project and accepts inputs in VScode

How can I create and run a Dart console application Using VS Code? I tried to accept via vscode. I kept getting "global evaluation requires a thread to have been loaded vscode"
Just run with the following command:
cd <PROJECT_FOLDER>
dart run bin/<NAME_OF_YOUR_DART_FILE>.dart

Dart 2.7.1 webdev 2.5.4 build throws Unhandled exception: Instance of 'MissingPortFile'

after upgrading Dart to 2.7.1 I get an Unhandled exception: Instance of 'MissingPortFile' when building the app with webdev 2.5.4. I have two AngularDart projects (Owner, Admin) sharing some code (Common). When I run webdev in Admin, I get the exception on the first run, on the second it starts. When I run webdev in Owner, I get the exception every time and then it won't start. The webdev command is the same in both projects (except the port number).
Admin: pub global activate webdev 2.5.4 && pub global run webdev serve --auto=refresh --hostname 127.0.0.1 "web:53311"
Owner: pub global activate webdev 2.5.4 && pub global run webdev serve --auto=refresh --hostname 127.0.0.1 "web:53322"
When I switch to devel Dart (2.8.0-dev.5.0) it works fine in both projects every time.
Is it some known issue of Dart 2.7.x? I didn't find it too much, except https://gitter.im/dart-lang/angular. They mention it should work when invoking webdev from Webstorm IDE, it didn't help me.
Edit: (more observations). After a successful build with Dart 2.8.0-dev5.0 I switched back to 2.7.1 and webdev started fine. So I removed .dart_tool folder and restarted webdev (still on Dart 2.7.1) and I got the exception again. So the problem is maybe in some files generated in .dart_tool.
Edit2: it's Dart independent. After several runs, I encountered the same problem with Dart 2.8.0-dev.5.0 and vice versa I succeeded with Dart 2.7.1 after several runs. But it's very unstable and I cannot determine what's the problem. From the exception desc MissingProtFile I would suspect that webdev creates some port file during build and some other process removes this file meanwhile. Maybe the file is created in some tmp directory. Can someone confirm my suspicion?

How to update to UiAutomator2?

I have some Robot Framework tests for Android device which I'm running. I'm currently using Windows10 computer to develop those tests.
I just installed version v1.15.0-1 of Appium. By default this new Appium is using UIAutomator2. Not anymore UIAutomator1. My problem is, that I have installed UIAutomator2, but Appium not seem to find that. Only way I can run my tests is to use UIAutomator1.
I have installed UIAutomator2 driver:
npm -g install appium-uiautomator2-driver
Not working:
Open Application ${REMOTE_URL} platformName=${PLATFORM_NAME} platformVersion=${PLATFORM_VERSION} deviceName=${DEVICE_NAME} appPackage=${${ENV}_APP_PACKAGE} automationName=UiAutomator2 app=${${ENV}_APP} appActivity=com.dummyfi.viestit.ui.splash.SplashActivity noReset=True
Working:
Open Application ${REMOTE_URL} platformName=${PLATFORM_NAME} platformVersion=${PLATFORM_VERSION} deviceName=${DEVICE_NAME} appPackage=${${ENV}_APP_PACKAGE} automationName=UiAutomator1 app=${${ENV}_APP} appActivity=com.dummyfi.viestit.ui.splash.SplashActivity noReset=True
This is what I get, when I'm trying to run tests with UIAutomator2:
Suite setup failed:
WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: The application at 'fi.dummy.viestit.sa' does not exist or is not accessible
With UIAutomator1, everything is working fine.

Appium - AWS device farm

I get an error as below when I try to run my tests on device farm.
testAppiumMethod failed: Invalid server instance exception has occured:
There is no installed nodes! Please install node via NPM
(https://www.npmjs.com/package/appium#using-node-js) or download and
install Appium app (http://appium.io/downloads.html)
I have installed Appium globally on local machine and the tests run fine. But they fail on device farm(have included all the dependencies). Can somebody help me out?
I believe you are trying to invoke the Appium server through your code, which is not required in Device Farm. Device farm has a Test Spec file (which is a yaml file) which does it for you, so all yo need to do is connect your driver to the invoked Appium server.
When you get the chance would you be able to provide this info:
appium verion being used
Specific method that the this failed on/code
snippet
Programming language Java/python
How exactly are the test being packaged and uploaded? Are we using the web console or the SDK/CLI?
Is this a web app tests or native app tests?
Also, to rule out an issue with a specific device would we be able to run the AWS Sample app/test on the same device?
Assuming this is an android test execute these commands to build the sample app:
git clone https://github.com/awslabs/aws-device-farm-sample-app-for-android.git
cd aws-device-farm-sample-app-for-android/
./gradlew cC
The app-debug.apk should be located in ./app/build/outputs/apk/
Then clone the sample appium testng tests:
git clone https://github.com/awslabs/aws-device-farm-appium-tests-for-sample-app.git
cd aws-device-farm-appium-tests-for-sample-app/
mvn clean package -DskipTests=true
The test pacakge "zip-with-dependencies.zip" should be located in the ./target directory
My apologies for adding all these questions as an answer. I look forward to your response.
HTH James
Seems to me that you need to install node on your AWS instance.
See below:
https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html

Is there a way to get JUnit code coverage when running in the browser?

We are currently working on getting better code coverage for one of our JS libraries. I have the The Intern up and running, and can run tests in the browser. However, our libraries create DOM elements in some of their functions, making it so we can't run JUnit from the terminal because Node.js doesn't allow for DOM construction in tests. Is there a way we can get JUnit code coverage on the html and console output we get when we run The Intern in the browser?
I found the answer. From this link: https://theintern.github.io/intern/#local-selenium
Using ChromeDriver (Chrome-only)
If you’re just looking to have a local environment for developing functional tests, a stand-alone ChromeDriver installation works great.
1. Download the latest version of ChromeDriver
2. Set tunnel to 'NullTunnel'
3. Run chromedriver --port=4444 --url-base=wd/hub
4. Set your environments capabilities to [ { browserName: 'chrome' } ]
5. Run the test runner
Once you have that setup and running, you can run
node_modules/intern/bin/intern-runner.js config=tests/intern reporters=JUnit filename=junit.xml
This will allow the tests to run in a chrome instance, and then output the results to a report that can then be upload somewhere.

Resources