only 1 file is ever executed under my tests/ folder for TestCafe - testing

I have multiple test_*.js files underneath a /testcafe/tests/folder. When executing TestCafe from commandline OR via Visual Studio, only ONE file is ever executed....why would that be?
tests (folder)
test_somefilename.js
test_someOtherfilename.js
test_onlyfileexecuted.js
test_anotherfilename.js
When running the following command, only 1 of the files is ever executed:
testcafe <pathToTestFolder>/tests/*.js
this will only ever execute the file named test_onlyfileexecuted.js
WHY? I can manually type in the command to execute every single file and TestCafe works perfectly, but when doing glob pattern, that is the only tests found/executed....So Confused

Just run testcafe {browser} <pathToTestFolder>/tests/ (no *.js) and Testcafe will automatically pick up all the tests in that directory

Related

Getting 'Could not find test files' Error when attempting to run TestCafe tests

I'm trying to run some TestCafe tests from our build server, but getting the following error...
"Could not find test files at the following location: "C:\Testing\TestCafe".
Check patterns for errors:
tests/my-test.ts
or launch TestCafe from a different directory."
I did have them running or able to be found on this machine previously, but others have taken over the test coding and changed the structure a bit when moving it to a Git repository. Now when I grab the tests from Git and try to run, the problem presents itself. I'm not sure if there is something in a config file that needs adjustment but don't know where to start looking.
The intention is to have it part of our CI process, but the problem is also seen when I attempt to run the tests from the command line. The build process does install TestCafe, but there is something strange around this as well.
When the build failes with the can't find tests error, if I try to run the following command in the proper location...
tescafe chrome tests/my-test.ts
... I get, 'testcafe' is not recognized as an internal or external command,
operable program or batch file.
Just can't understand why I can't get these tests running. TestCafe setup was pretty much easy previously.
ADDENDUM: I've added a screenshot of the working directory where I cd to and run the testcafe command as well as the tests subdirectory containing the test I'm trying to run.
Any help is appreciated!!
testcafe chrome tests/my-test.ts is just a template; it isn't a real path to your tests. This error means that the path that you set in CLI is wrong, and there aren't any tests. You need to:
Find out where you start CLI. Please attach a screenshot to your question.
Define an absolute path to tests or a path relative to the place where CLI was started. Please share a screenshot of your project tree where the directory with tests is open.
Also, you missed t in the tescafe chrome tests/my-test.ts command. It should be tesTcafe chrome tests/my-test.ts. That is why you get the "'tescafe' is not recognized as an internal or external command" error.
I was able to get things working by starting from scratch. I uninstalled TestCafe and cleaned the working folder. During next build it was fine. I'm sure I've tried this several times, but it just started working.
One positive that came out of it was that I discovered a typo in a test file name, which was also causing issues finding the test I was using to check testing setup.
Thanks for helping!!

Validate that NUnit's ITestEventListener within Jenkins Pipeline for a netcoreapp3.1 assembly is called

Locally, I have successfully implemented the interface ITestEventListener within a C# netcoreapp3.1 csproj. However, when the tests are an within a Jenkins Pipeline, things appear to not be working(?).
I am using version 3.12.0 of NUnit.Engine.
By locally I am referring to using 1) Visual Studio Version 16.9.2 to run the tests and 2) command line dotnet test -c devint --test-adapter-path:. --logger:nunit to run the tests. I am getting successful test runs.
Success is my [Extension]public class ReportTestListener : ITestEventListener {...} generates an html file. I am to see the html file is created locally whereas from the Jenkins Pipeline the html file is not generated.
Within the Jenkins Pipeline, I am using the command sh "dotnet test -c ${env.TARGET_ENV} --test-adapter-path:. --logger:nunit" where env.TARGET_ENV resolves to devint. I know tests successfully run within the Jenkins Pipeline since the NUnit test results file is generated/published.
What I am not sure of is how to test/validate that the ReportTestListener is being called within the Jenkins Pipeline. I know that testing frameworks such as NUnit uses refection to identify test classes and methods. I am presuming that also happens with my implementation of [Extension]public class ReportTestListener : ITestEventListener {...}. Ideas/Suggestions on how to validate that ITestEventListener's method void OnTestEvent(string report) is being called besides writing out to disk?
Changed file writing text path to use / instead of \.

How to run CI selenium side runner tests on Jenkins

I have a .side file generated by the Selenium IDE, which I need to run on CI using Jenkins.
I am running it as a build step with the following shell command:
selenium-side-runner /path/to/file.ide
The problem arises due to the fact that no matter if the selenium test fails, Jenkins always shows is as success.
In this thread it's suggested to upload the file as generic, but still, the commands to execute it are missing
How to upload a generic file into a Jenkins job?
I've found a possible solution to it on this posts, but I would appreciate having a cleaner way to solve this instead of parsing the results checking for errors.
How to mark a build unstable in Jenkins when running shell scripts
Is there a plugin able to run selenium .side files on Jenkins and this one showing the success/failures of the test?
You can generate a Junit test report file and then use the Jenkins Junit plugin after your tests execution.
selenium-side-runner --output-directory=results --output-format=junit
# Outputs results in `junit` frormat in `./results/projectName.xml'
Check the official documentation for more details.

SpecRun.exe: run .feature or .playlist file from command line

Good day. I have a several .feature files:
1.feature
2.feature
1.playlist
2.playlist
etc.
I can run they separatelly in visual studio:
-any feature file in debug mode
-any playlist with Test Explorer.
But if i need to run one of they from command line, what i should do?
If i use SpecRun.exe run
SpecRun.exe run %profile%.srprofile "/baseFolder:%~dp0\bin\Debug" /log:specrun.log
this performs launch of ALL scenarios in ALL .feature files.
Have a look at the command line switches of the SpecRun.exe here http://specflow.org/plus/documentation/SpecFlowPlus-Runner-Command-Line/
You are looking for /filter to filter your execution to a single scenario.
The format of it is documented here: http://specflow.org/plus/documentation/SpecFlowPlus-Runner-Profiles/#Filter

Debugging individual protractor files with WebStorm

I want to be able to right click on an individual protractor test, click debug or run and have it execute. I can do this from the command line but I want to be able to debug with WebStorm to leverage the debugger.
By default when right clicking and debugging a file webstorm runs:
runnerw.exe "C:\Program Files\nodejs\node.exe"
--debug-brk=57698 --nolazy myspec.js
Can I have it run the following substituting the filename which I've selected:
node node_modules\protractor\bin\protractor protractor.dev.conf.js
--specs "/specs/myspec.js"
As a crappy work around I have the following:
This runs a single file but I need to edit the configuration each time to change the spec i'm testing.
protractor.dev.conf.js --specs "myproject/specs/test0043.js"
Does WebStorm allow you to dynamically substitute the test file?
Thanks
Can I do have it run the following substituting the file I've selected:
node node_modules\protractor\bin\protractor protractor.dev.conf.js
--specs "/specs/myspec.js"
and can you run the same not using WebStorm (in command line)? If you can, it's not a problem to do the same in webstorm
try ddescribe and iit
iit('should ...')
Will run only those tests marked with iit.
ddescribe will only run the tests under that suite(s)
Try the ddescriber plugin http://plugins.jetbrains.com/plugin/7233?pr=phpStorm