Android Unit Test :- Class not found "package name " Empty test suite - unit-testing

Getting this error with message :-
Process finished with exit code 1
Class not found: “com.example.app.ken.finding_driver.instant.FindingDriverFlowTest” Empty test suite.

You have to check and make sure - your Java source code path and test class path should be exactly same. Log-cat did not show this error

Related

Testing base code with wasm-pack test throws "use of undeclared crate or module" error

Could someone tell me what I'm doing wrong here ? I've written script entries in package.json, which one for tests looks like this
"test:headless": "cross-env RUSTFLAGS=\"-C target-feature=+atomics,+bulk-memory,+mutable-globals,+simd128\" rustup run nightly-2022-04-07 wasm-pack test --headless --chrome -- -Z build-std=panic_abort,std",
altought executed test cannot recognize wasm-rayon namespace which is my base code.
here is code to repo: https://github.com/MalwareX95/wasm-playground
I had to add rlib in crate-type: https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/template-deep-dive/cargo-toml.html
We also specify crate-type = ["rlib"] to ensure that our library can be unit tested with wasm-pack test.

Rust tests fail to even run

I'm writing a project to learn how to use Rust and I'm calling my project future-finance-labs. After writing some basic functions and verifying the app can be built I wanted to include some tests, located in aggregates/mod.rs. [The tests are in the same file as the actual code as per the documentation.] I'm unable to get the tests to run despite following the documentation to the best of my ability. I have tried to build the project using PowerShell as well as Bash. [It fails to run on Fedora Linux as well]
Here is my output on Bash:
~/future-finance-labs$ cargo test -- src/formatters/mod.rs
Finished test [unoptimized + debuginfo] target(s) in 5.98s
Running target/debug/deps/future_finance_labs-16ed066e1ea3b9a1
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Using PowerShell I get the same output with some errors like the following:
error: failed to remove C:\Users\jhale\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\home\jhale\future-finance-labs\target\debug\build\mime_guess-890328c8763afc22\build_script_build-890328c8763afc22.build_script_build.c22di3i8-cgu.0.rcgu.o: The system cannot find the path specified. (os error 3)
After my initial excitement at the prospect of writing a few tests that passed on the first attempt, I quickly realized all the green was indicative; rather, of a failure to even run the tests. I just want to run the unit tests. Running cargo test alone without a separate and file fails as well. Why can't I run any test in this project with my current setup?
It can't find your test because the rust compiler doesn't know about it. You need to add mod aggregates to main.
mod aggregates;
fn main() {
println!("Hello, world!");
}
After you do that, you'll see that your aggregates/mod.rs doesn't compile for many reasons.
And as Mihir was trying to say, you need to use the name of the test, not the name of the file to run a specific test:
cargo test min_works
cargo test aggregates
See also:
How do I “use” or import a local Rust file?
Rust Book: Controlling How Tests Are Run

Which unit test is currently running?

This question is related to the problem where my unit test procedure is crashing but I don't know on which unit test.
I realise this question is a duplicate of How can I find out which test method in a batch of test methods fails to run? but I need to try anyway:
I'm running some unit tests (about 118 of them), but one of them seems to make the Visual Studio unit test environment crash. This is what I see in the "output" window's "Tests" tab:
[5/02/2018 11:13:18 Informational] ------ Run test started ------
[5/02/2018 11:13:38 Error] The active Test Run was aborted because the execution process exited unexpectedly. The test execution process crashed while running the tests. To investigate further, open file:///C:/Users/DominiqueDS/AppData/Local/CrashDumps/vstest.executionengine.x86.exe.19136.dmp file in Visual Studio and choose "Debug in mixed mode".
[5/02/2018 11:13:38 Informational] ========== Run test finished: 65 run (0:00:19,6926824) ==========
The reason that I have that dump file is thanks to my Windows configuration which automatically creates such dumpfiles in case of a crashing application. (The procedure for this configuration is found under this URL)
Examining the dump file gives me more information on the test, which is failing: I have a hunch where I can find it, and in another thread, I find a function, calling a method which seems to contain the name of the unit test I'm running.
Although I know which test is failing, it's based on hunches and on dumpfiles I should even not generate, so I'm looking for another solution:
In the function TEST_METHOD in the file "c:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\VS\UnitTest\include\CppUnitTest.h", I've tried to add the following lines:
cout << "Test : ";\
cout << methodName;\
cout << "\n";\
I was hoping that this would show every test I wanted to run, but instead I get the error message that this is wrong (also using std::cout and OutputDebugString() function seems not to be allowed).
Hence my question: does anybody know a way to find out, in case one of my unit tests makes my test environment crash, how can I find out which test this is, without needing to generate and debug the Visual Studio dumpfile?
For your information: looking in the "Test Explorer" is not helping: I have a list of disabled tests, a list of successful ones, and a list of some which are not finished, and my failing test is not the first of the "not finished" ones.
Found it: I've added the following line in the definition of TEST_METHOD():
Microsoft::VisualStudio::CppUnitTestFramework::Logger::WriteMessage(L#methodName);\

XCode and SenTestingKit not outputting to the editor window

I am new to testing in Xcode. I am following the developer documentation "iOS Developement Guide" Unit Testing Applications.
I have successfully added unit test bundles to my application with one failing test.
When I build the test target the output shows 1 error as expected but the editor does not show the expected error message under the failed test.
Does anyone know any configurations that need to be set to enable this feature?
Apples docs say:
"If the unit-test bundle is configured correctly, the build fails and Xcode displays an error message in the text editor."
TIA
Vital Clue:
- One thing I have noticed in my output window is the message "Command /bin/sh failed with exit code 1"
Try to follow this guide
Be double careful about when to set application target, and when to set Unit test target. It works fine for me though.
If Unit Test fail, there should be some messages shown in the console.

Boost unit test failure detected in wrong test suite

I'm learning how to use the Boost Test Library at the moment, and I can't seem to get test suites to work correctly. In the following code 'test_case_1' fails correctly but it's reported as being in the Master Test Suite instead of 'test_suite_1'.
Anyone know what I'm doing wrong?
#define BOOST_AUTO_TEST_MAIN
#include <boost/test/auto_unit_test.hpp>
BOOST_AUTO_TEST_SUITE(test_suite_1);
BOOST_AUTO_TEST_CASE(test_case_1) {
BOOST_REQUIRE_EQUAL(1, 2);
}
BOOST_AUTO_TEST_SUITE_END();
edit:
Ovanes' answer led me to understand the suite hierarchy better - in this case test_suite_1 is a sub-suite of the root suite which by default is named 'Master Test Suite'. The default logging only shows the root suite, which isn't what I expected by I can deal with it :)
You can set the root suite name by defining BOOST_TEST_MODULE - so an alternative version of the above example which gives the expected error message is:
#define BOOST_TEST_MODULE test_suite_1
#define BOOST_AUTO_TEST_MAIN
#include <boost/test/auto_unit_test.hpp>
BOOST_AUTO_TEST_CASE(test_case_1) {
BOOST_REQUIRE_EQUAL(1, 2);
}
It depends how you configure your logger to produce the report. For example passing to your example --log_level=all will result in the following output:
Running 1 test case...
Entering test suite "Master Test Suite"
Entering test suite "test_suite_1"
Entering test case "test_case_1"
d:/projects/cpp/test/main.cpp(9): fatal error in "test_case_1": critical check 1 == 2 failed [1 != 2]
Leaving test case "test_case_1"
Leaving test suite "test_suite_1"
Leaving test suite "Master Test Suite"
*** 1 failure detected in test suite "Master Test Suite"
Here is the link to the command line config options of Boost Test Framework.
Regards,
Ovanes
Also, once you define BOOST_TEST_MODULE, you don't need to define BOOST_AUTO_TEST_MAIN