testTags() test method not recognized as test in my gradle project, using junit5 [duplicate] - gradle

This question already has an answer here:
Unable to use read('classpath:') when running tests with standalone karate.jar
(1 answer)
Closed 2 years ago.
I added below test methods to my runner class. When I try to run the testTags() test, I get 'No tests found for given includes: ....' and 'Test events were not received' (in my IDE) errors. I have ensured that the "#test1" tag is a valid tag in my feature file.
The testFullPath() method runs my entire feature, as expected. But when I try to implement other test methods, they are not recognized.
I'm using karate-junit5:0.9.5.RC5
package WebServices.Regression;
import com.intuit.karate.junit5.Karate;
public class Regression_Runner {
#Karate.Test
Karate testFullPath() {
return new Karate().feature("regressionTest.feature").relativeTo(getClass());
}
#Karate.Test
Karate testTags() {
return new Karate().feature("regressionTest.feature").tags("#test1").relativeTo(getClass());
}
}

There's no need to have everything relativeTo(someClass) just use this form:
return Karate.run("classpath:/some/package/regressionTest.feature")
Else sorry nothing anyone can do, please follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue
Maybe you are better off using the ZIP release: https://github.com/intuit/karate/wiki/ZIP-Release

Related

Getting the error "Cannot find module './commands'" while trying to run cypress tests

When I'm trying to run cypress test I'm getting this error:
The following error originated from your test code, not from Cypress.
\> Cannot find module './commands'
When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.
Cypress could not associate this error to any specific test.
We dynamically generated a new test to display this failure.
I was expecting my tests to run, and I've tried to create an index.js in the support folder with:
import './commands'
Cypress.on('uncaught:exception', (err, runnable) => {
return false;
})
But that doesn't seem to work.
When I had this issue it was because I tried to import from the wrong file.
Instead of importing in the test file, commands should be imported into /cypress/support/e2e(.js|.ts) file.
Ref Custom Commands
We recommend defining queries is in your cypress/support/commands.js file, since it is loaded before any test files are evaluated via an import statement in the supportFile.
That way they are available in any test that requires them. This is because the /cypress/support/e2e.js file is automatically integrated into the start of any and all test runs.

Cucumber-cpp step defiinition runner exits immediately

Based on the instructions given at cucumber-cpp github repo and cucumber-cpp step definition quick-start guide , I created my cucumber step definition files. The features and their step_definition files are under features/ folder, and the cpp code is built with cucumber-cpp headers and linked against libcucumber-cpp.a as instructed.
Cucumber step definition runners should stay running as a seperate process and cucumber command should execute while the runner is running. Indeed, the examples in the cucumber-cpp repository execute like that, but when I create my own step definitions, with gtest or boost test, they execute immediately, without waiting for calls from cucumber.
Onats-MacBook-Pro:bin onatbas$ ./tests/AdditionTest_TESTTARGET
Running main() from gtest_main.cc
[==========] Running 0 tests from 0 test cases.
[==========] 0 tests from 0 test cases ran. (0 ms total)
[ PASSED ] 0 tests.
Onats-MacBook-Pro:bin onatbas$
Instead of executing immediately, it should say nothing and wait for cucumber calls. I copy-pasted the example code from the cucumber-cpp into my project and they, too, exit immediately. So even though there's no source code difference between cucumber-cpp's examples and mine, they act differently.
I suspected the cmake build scripts might be linking with different libraries, but the linkage process is exactly the same too.
Does anybody have any idea on why this might be happening?
Here's the repository with minimum code that reproduces the error I have. https://github.com/onatbas/CucumberCppTest
The complete trace is at readme.
The cucumber files are under features/, and ther's only one feature that's identical to what's here
The runner executable is defined in tests/CMakeLists.txt
For quick reference: Here's the step-definition file
AdditionTest.cxx
#include <boost/test/unit_test.hpp>
#include <cucumber-cpp/defs.hpp>
#include <CucumberApp.hxx>
using cucumber::ScenarioScope;
struct CalcCtx {
Calculator calc;
double result;
};
GIVEN("^I have entered (\\d+) into the calculator$") {
REGEX_PARAM(double, n);
ScenarioScope<CalcCtx> context;
context->calc.push(n);
}
WHEN("^I press add") {
ScenarioScope<CalcCtx> context;
context->result = context->calc.add();
}
WHEN("^I press divide") {
ScenarioScope<CalcCtx> context;
context->result = context->calc.divide();
}
THEN("^the result should be (.*) on the screen$") {
REGEX_PARAM(double, expected);
ScenarioScope<CalcCtx> context;
BOOST_CHECK_EQUAL(expected, context->result);
}
and here's the tests/CMakeLists.txt file where the executable is added.
cmake_minimum_required(VERSION 3.1)
find_package(Threads)
set(CUCUMBERTEST_TEST_DEPENDENCIES cucumberTest
${CMAKE_THREAD_LIBS_INIT}
${GTEST_BOTH_LIBRARIES}
${GMOCK_BOTH_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${Boost_LIBRARIES}
${CUCUMBER_BINARIES}
)
macro(ADD_NEW_CUCUMBER_TEST TEST_SOURCE FOLDER_NAME)
set (TARGET_NAME ${TEST_SOURCE}_TESTTARGET)
add_executable(${TARGET_NAME} ${CMAKE_SOURCE_DIR}/features/step_definitions/${TEST_SOURCE})
target_link_libraries(${TARGET_NAME} ${CUCUMBERTEST_TEST_DEPENDENCIES})
add_test(NAME ${TEST_SOURCE} COMMAND ${TARGET_NAME})
set_property(TARGET ${TARGET_NAME} PROPERTY FOLDER ${FOLDER_NAME})
endmacro()
ADD_NEW_CUCUMBER_TEST(AdditionTest "cucumberTest_tests")
Your example outputs
Running main() from gtest_main.cc
That main method will run the test runner's default behaviour instead of Cucumber-CPP's. The main mathod that you want (src/main.cpp) is included as part of the compiled cucumber-cpp library.
Try moving ${CUCUMBER_BINARIES} in CUCUMBERTEST_TEST_DEPENDENCIES before all others, or linking to testing libraries that do not contain a main method (e.g. GoogleTest ships with two libraries: one with and one without the main method).

Is there a way to issue a warning when running tests with XCTest?

I have a project that imports a Git submodule to run a part of an XCTest test suite. If the submodule is not available (not checked out), I want the test suite to succeed, but issue a warning that not all tests were run. Is that possible?
Searching for similar issue I have found out that we could add messages to test logs as string attachments. If you want to have a warning sign you can add ⚠️ emoji in name.
Here is a function example that adds it.
func addLogMessage(_ message: String, attachmentLifetime: XCTAttachment.Lifetime = .keepAlways) {
XCTContext.runActivity(named: "Log message") { activity in
let messageAttachment = XCTAttachment(string: message)
messageAttachment.lifetime = attachmentLifetime
activity.add(messageAttachment)
}
}

Elixir TDD tests only execute when a test file is saved

I have a fresh installation of Laravel 5.1, and am trying to run automated tests using Elixir. According to documentation, I can run gulp tdd and have my tests execute automatically each time a file is saved. I have the initial ExampleTest.php which has this test:
public function testBasicExample()
{
$this->visit('/')
->see('Laravel 5');
}
This test asserts if the default welcome.blade.php file shows Laravel 5. Each time when I save the ExampleTest.php file, the automated tests do execute, and that's great. But when I change and save the welcome.blade.php file, the tests do not execute automatically.
Is this the desired behaviour or not? If not, what could be causing it?
By default elixir comes with two tasks for your test suites. One for phpunit and the other for phpspec, in your gulpfile phpUnit method is called on the mix object for phpunit test suite.
mix.phpUnit();
mix.phpSpec();
And then you need to type Gulp watchfrom terminal.

Grails test-app updating function being tested and test print out problems

I am running grails 2.3.3 in a GGTS.
I am successfully running a single unit test for a service function within the Spring GGTS.
I am hoping to be able to use this unit test to develop the particular function - such an approach will really speed up my development going forward.
This means I need to make changes to the service function that is being tested and then retest over and over again (no doubt a sad reflection on my coding skills!). The problem is when I make a change to the logic or any log.debug output it does not come through in the test. In other words the test continues to run against the original service function and not the updated one.
In order for me to force it to use the updated function the only way I have found that will do this is to restart the GGTS!
Is there a command I can use in GGTS to force a test on the most recent version of the function I am testing?
Here are the commands I am using within the GTTS:
test-app unit: UtilsService
I do run a clean after a function update without any success:
test-app -clean
I am also struggling with getting additional output from within the test function - introducing 'println' or 'log.debug' commands results in a failure of the test.
It would be useful to know of a good link to documentation about the test syntax - I have looked at grails section 12 about testing in general.
Here is the test file:
package homevu1
import grails.test.mixin.TestFor
import spock.lang.Specification
/**
* See the API for {#link grails.test.mixin.services.ServiceUnitTestMixin} for usage instructions
*/
#TestFor(UtilsService)
class UtilsServiceSpec extends Specification {
// to test utilSumTimes for example use the command :
// test-app utilSumTimes
// test-app HotelStay
def setup() {
}
def cleanup() {
}
void "test something"() {
when:
def currSec = service.utilSumTimeSecs( 27, 1, false)
//println "currSec" , currSec
then:
//println "currSec" , currSec
assert currSec == "26"
}
}
If I uncomment either of the println lines these comments are not displayed and the test fails.
Welcome any suggestions.
-mike
I've to get this working now by running grail from a command prompt (in MS Windows).
In the command prompt I moved to the root folder/directory of the grails project - in my case:
cd C:\grails\workspace\rel_3.1.0\HomeVu
Then I type grails to start a grails command line session.
The unit test command I used being:
test-app -unit UtilsService -echoOut -echoErr
That said I still am unable to successfully put any print commands in the test file - but I can use the assert to determine any problems.
Also output from the last log.debug line of the grails code of the service function fails to appears. Perhaps there is some output buffering issue with MS Windows here.
At least I can now do some rapid function development, by making changes to the service/function code and instantly test is against a set of known requirement conditions.
Hope this helps others.
-mike

Resources