Would like to use jest.retryTimes() & for that I have installed jest-circus however while running test getting jasmine not define error .
To achieve above I have added testRunner: "jest-circus/runner" in jest.config.js
I am using puppeteer framework with jest test runner.
Exact error :
Test suite failed to run
ReferenceError: jasmine is not defined
at registerAllureReporter (node_modules/jest-allure/dist/setup.js:46:5) at Object. (node_modules/jest-allure/dist/setup.js:49:1)
Please check my answer to the similar question regarding undefined jasmine with jest-circus runner being used: https://stackoverflow.com/a/66073466/1445507
Related
Me and my team just moved from JUnit4 to JUnit5 and we faced with parallelism issues. With 4th version we used -Dcucumber.options="--threads 5" to run in tests several threads, but after deprecation and removing of cucumber options it's obviously doesn't work anymore. I set up (at least I think so) junit platform engine for the project (https://github.com/cucumber/cucumber-jvm/tree/main/cucumber-junit-platform-engine#configuration-options), but when I try to run tests via comand line (using Gradle task), I receive following error:
UnknownClass.Cucumber > UnknownClass.initializationError FAILED
org.junit.platform.commons.JUnitException at EngineExecutionOrchestrator.java:114
Caused by: org.junit.platform.commons.JUnitException at HierarchicalTestEngine.java:57
Caused by: org.junit.platform.commons.JUnitException at DefaultParallelExecutionConfigurationStrategy.java:41
Unfortunately, didn't find something in the internet, maybe someone can help with it?
What we use:
Spring boot 2.7.3
Gradle 7.5.1
Cucumber java, junit, spring, junit-platform-engine 5.7.0
junit-platform-suite-api 1.3.2
Tasks in build.gradle that I have now:
useJUnitPlatform()
systemProperty("cucumber.junit-platform.naming-strategy", "long")
systemProperty("cucumber.execution.parallel.enabled", true)
systemProperty("cucumber.execution.parallel.config.strategy", "fixed")
systemProperty("cucumber.plugin", "html:reports/html")
systemProperty("cucumber.plugin", "pretty")
systemProperty("cucumber.plugin", "junit:reports/junit")
doLast {
javaexec {
mainClass.set("io.cucumber.core.cli.Main")
classpath = cucumberRuntime + sourceSets.test.get().output + sourceSets.main.get().output
}
}
}
tasks {
val consoleLauncherTest by registering(JavaExec::class) {
dependsOn(testClasses)
val reportsDir = file("$buildDir/test-results")
outputs.dir(reportsDir)
classpath = sourceSets["test"].runtimeClasspath
mainClass.set("org.junit.platform.console.ConsoleLauncher")
args("--scan-classpath")
args("--include-engine", "cucumber")
args("--reports-dir", reportsDir)
}
test {
dependsOn(consoleLauncherTest)
exclude("**/*")
}
}
Configuration class:
#CucumberContextConfiguration
#Suite
#IncludeEngines("cucumber")
#SelectClasspathResource("com/example")
#ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "com.example")
#SpringBootTest
#ContextConfiguration(classes = [IntegrationContext::class], loader = SpringBootContextLoader::class)
class Application() {}
Your question is pretty much impossible to answer because you didn't go through the process of making a minimal reproducer. For your next question please read the "Help others reproduce the problem" section in How do I ask a good question?.
With 4th version we used -Dcucumber.options="--threads 5" to run in tests several threads, but after deprecation and removing of cucumber options it's obviously doesn't work anymore.
Project typically include a CHANGELOG and release notes documenting all relevant changes.
What we use:
Spring boot 2.7.3
Cucumber java, junit, spring, junit-platform-engine 5.7.0
junit-platform-suite-api 1.3.2
These dependencies don't converge and aren't quite correct. You'll want to use Cucumber's and JUnit's Bill of Materials to avoid having to specify the version for every module.
If you're using Spring Boot in the recommended way you may also be able to omit the junit-bom altogether.
dependencies {
testImplementation(platform("org.junit:junit-bom:5.9.1"))
testImplementation(platform("io.cucumber:cucumber-bom:7.9.0"))
testImplementation("io.cucumber:cucumber-java")
testImplementation("io.cucumber:cucumber-junit-platform-engine")
testImplementation("org.junit.platform:junit-platform-suite")
testImplementation("org.junit.jupiter:junit-jupiter")
}
Tasks in build.gradle that I have now:
So in this build file it appears that you are trying to run Cucumber in 3 different ways. Through the JUnit Platform, through Cucumbers CLI and through the JUnit 5 ConsoleLauncher.
I don't know which solution you are trying use but suppose that you want to use the JUnit Platform, then you look at cucumber-java-skeleton for a working example.
Then afterwards you should clean up your build file. :D
I have a "Property Content" JsonPath Existence Match assertion for a Test Step in a test case. Its a REST service and have assertion as following:
$.recommendedFood[0].calories
I have the following code def assertsize = testStep.getAssertionList().size()
This works fine when i print out running the groovy script on SOAP UI ( locally)log.info (testStep.getAssertionList().size()) output is 1
But the same when run on Jenkins, the size is printed as 0( no change in the script, but it doesnt recognize the test step.
Also i see error 23:41:42,500 ERROR [TestAssertionRegistry] Missing assertion for type [JsonPath Existence Match]
I tried solutions : SoapUI Testrunner giving error about TestAssertionRegistry
https://community.smartbear.com/t5/API-Functional-Security-Testing/Maven-Soapui-Plugin-with-json-assertions-does-not-work-well-in/td-p/106777
but could not solve the issue. Any solutions or fixes for that?
I am in the process of migrating an application to Angular 6 from Angular 5. at this point I believe I have most issues sorted out and when building with ng serve or ng build main it builds as expected. however when building as ng build --prod main I get the below error
ERROR in : Error: Illegal State: literal maps should have been converted into functions
at _AstToIrVisitor.visitLiteralMap (/workspace/tarnished-lamp/node_modules/#angular/compiler/bundles/compiler.umd.js:15824:19)
at LiteralMap.visit (/workspace/tarnished-lamp/node_modules/#angular/compiler/bundles/compiler.umd.js:3483:28)
at ASTWithSource.visit (/workspace/tarnished-lamp/node_modules/#angular/compiler/bundles/compiler.umd.js:3598:29)
at convertPropertyBinding (/workspace/tarnished-lamp/node_modules/#angular/compiler/bundles/compiler.umd.js:15626:52)
at createHostBindingsFunction (/workspace/tarnished-lamp/node_modules/#angular/compiler/bundles/compiler.umd.js:20068:39)
at baseDirectiveFields (/workspace/tarnished-lamp/node_modules/#angular/compiler/bundles/compiler.umd.js:19754:43)
at compileComponentFromMetadata (/workspace/tarnished-lamp/node_modules/#angular/compiler/bundles/compiler.umd.js:19793:29)
at compileComponentFromRender2 (/workspace/tarnished-lamp/node_modules/#angular/compiler/bundles/compiler.umd.js:19878:19)
at /workspace/tarnished-lamp/node_modules/#angular/compiler/bundles/compiler.umd.js:21551:21
at Array.forEach (<anonymous>)
at AotCompiler._compilePartialModule (/workspace/tarnished-lamp/node_modules/#angular/compiler/bundles/compiler.umd.js:21527:24)
at /workspace/tarnished-lamp/node_modules/#angular/compiler/bundles/compiler.umd.js:21509:58
at Array.forEach (<anonymous>)
at AotCompiler.emitAllPartialModules (/workspace/tarnished-lamp/node_modules/#angular/compiler/bundles/compiler.umd.js:21509:19)
at AngularCompilerProgram._emitRender3 (/workspace/tarnished-lamp/node_modules/#angular/compiler-cli/src/transformers/program.js:252:41)
at AngularCompilerProgram.emit (/workspace/tarnished-lamp/node_modules/#angular/compiler-cli/src/transformers/program.js:235:59)
I have two questions from this
What does this Error actually mean
How do I find it and correct it
Migrating from angular 6.0 to 7.0, I enabled ivy compiler and I got the same error.
Disabling ivy option, AOT build works again.
I'm running a unit test that makes a simple http call
karma.config.js, test.ts, tsconfig.js are all virgin boilerplate ng CLI 5.2.3, node, webpack and ts all latest versions. karma-webpack not used
The httpclient get call generates this error but only when run as a specified test in karma/jasmine/webpack:
TypeError: this.handler.handle is not a function at MergeMapSubscriber.WEBPACK_IMPORTED_MODULE_2_rxjs_operator_concatMap.a.call [as project] (:9876/_karma_webpack_/webpack:/C:/Users/sauna/Documents/adev/UK/node_modules/#angular/common/esm2015/http.js:1174)
at MergeMapSubscriber._tryNext (:9876/_karma_webpack_/webpack:/C:/Users/sauna/Documents/adev/UK/node_modules/rxjs/_esm2015/operators/m
This is the test specification that makes the http call as part of an an integration suite:
httpClientInstance.get('myAPIurlReturningAJsonObj').subscribe(
(data) => {
testID = data.MessageText;
},
(error) => {
console.log(error);
}
);
..expectation is any string to testID
the error is something with the Observable presented by ng not being handled by Jasmine
ping me I need to present more information, thx
Answering my own question may be wrong, new to StackOverflow - I hope I've found the answer. I believe that this error's a threading/socket issue. Accessing a Jasmine http request as a unit test doesn't seem possible without using Spy. I've solved the immediate problem using Protractor
I found that my Sonar instance 5.1 or 5.1.1 (with latest sonar-runner 2.x) stopped showing part of the Unit test info (Unit test widget) on the project's dashboard.
The properties I had were (in Gradle's sonarRunner > sonarProperties section):
property "sonar.junit.reportsPath", "build/test-results/UT"
property "sonar.surefire.reportsPath", "build/test-results/UT"
To fix it, I had to include the following properties as well:
property "sonar.java.junit.reportsPath", "build/test-results/UT"
property "sonar.java.surefire.reportsPath", "build/test-results/UT"
Just FYI: All my Unit tests reports go under build/test-results/UT folder, all Integration Tests result files go unedr build/test-results/IT folder and etc.
I'm wondering if this is due to Gradle version that I'm using (2.3) or is it due to a later version of SonarQube (4.5+) as I have both SQ 5.1 and 5.1.1 instance.
I know SonarQube team started Multi language support since SonarQube version 4.12
Since SonarQube 4.2, it is possible to run an analysis on a multi-language project.
Now, it raises a question. For Getting the same Unit test info for Groovy based projects, do I need to use:
property "sonar.groovy.junit.reportsPath", "build/test-results/UT"
property "sonar.groovy.surefire.reportsPath", "build/test-results/UT"
something like that if my project has Groovy code instead of java?
Searching "**sonar.java.junit.reportPath"** with using double quotes shows No results found in Google and it forces me to try and see google results if I can run the search again without using " double quotes (for this property).
Doing the same in SonarQube site "search box" shows:
No results found for sonar.java.junit.reportPath. Please try one of the following suggestions:
Though in Gradle, inside
sonarRunner task {
.. inside ..
sonarProperties {
... section ... where I define various sonar props..
}
...
}
I can define both sonar.junit.reportPath, sonar.java.junit.reportPath and similarly, sonar.surefire.reporPath and sonar.java.surefire.reportPath and while running sonarRunner task in Gradle, it doesn't error out. Thus it makes me believe that the property variables are valid.
There are also issues with running sonarRunner or stand alone sonar-runner command for a mixed Java and Groovy based project (i.e. source code in Java but tests in Groovy). Setting sonar.language=java,grvy didn't help. I posted this question on stackoverflow but so far I have no perfect result/answer on how to get a full fledged sonar dashboard up and running for a Groovy projects like I get for a Java project.
Groovy project - Sonar - Publish project and Unit + Integration Test code coverage data
PS: I have tried various values for setting sonar.. variables (as far a sonar source, tests, etc, etc properties are concerned, which they have mentioned on their site's docs section)
The only valid property to use as of now is sonar.junit.reportsPath which will tell the java sonarqube plugin where to import your result of unit tests.
For groovy, this is work in progress, see : http://jira.sonarsource.com/browse/SONARGROOV-2
All the other properties you mentioned do not exist and are not taken into account.