I have a problem using Junit tests with Java and Eclipse. All of my tests run just fine when I invoke them standalone. By this I mean that HDLmTreeTest, HDLmTreeTest1, and HDLmTreeTest2 all run fine when I run them by themselves. However, I have a Java source module with all of the test files in it. See below.
package com.headlamp;
import org.junit.platform.runner.JUnitPlatform;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.runner.RunWith;
#RunWith(JUnitPlatform.class)
#SelectClasses({HDLmConfigTest.class, HDLmDefinesTest.class,
HDLmErrorTest.class, HDLmStringTest.class, HDLmTreeTest.class,
HDLmTreeTest1.class, HDLmTreeTest2.class,
HDLmModTest.class, HDLmBuildJSTest.class, HDLmFindTest.class,
HDLmAssertTest.class, HDLmBuildLinesTest.class, HDLmUtilityTest.class,
HDLmSavedChangeTest.class, HDLmCurlApacheTest.class, HDLmMainTest.class,
HDLmJettyTest.class, HDLmCurlJettyTest.class, HDLmEditorServletTest.class,
HDLmApacheTest.class, HDLmProxyTest.class, HDLmSessionTest.class,
HDLmLogMsgTest.class, HDLmMatchTest.class, HDLmImageInformationTest.class,
HDLmClusteringTest.class, HDLmJsonTest.class})
class HDLmAllTests { }
When I run this file, all of my tests get invoked except for HDLmTreeTest1.class and HDLmTreeTest2.class. I should say that HDLmTreeTest1.class and HDLmTreeTest2.class were just recently created and added to the SelectClasses list. For some reason, they are not invoked, but all of the other classes are invoked. What am I doing wrong?
I figured this out (with lots of online help). The problem was the name(s) of my test classes. Test classes (the names of test classes) must end with 'Test' or 'Tests'. They can not end with 'Test1' or 'Test2'. That was my error. I changed the class names and the problem went away. See https://howtodoinjava.com/junit5/junit5-test-suites-examples/ for some details.
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
when #beforeclass executes assertion failure , it is not causing test result to fail in jenkins. how can I change this to failure.
You need to add a post build step to check the junit test results. We use "Publish JUnit test result report" and add the location where the results output (xml files) are stored.
I am using Selenium 2.0 with the WebDriver. I am not using the TestCaseBase, etc. I am using only the webdriver.
I am also using JUnit with the Parameterized test.
When running tests with the IEDriver - the first test runs fine, the second test gets a org.apache.http.conn.HttpHostConnectException.
Does anyone have experience with this?
Does this seem like a bug or bad code?
Thanks in advance.
Try use driver.quit() instead of driver.close()
See this: http://groups.google.com/group/webdriver/browse_thread/thread/6ade9e6ae1861a2/e1fd6423589b5d1d?lnk=gst&q=internetexplorerdriver+connection++refuse#e1fd6423589b5d1d
Puzzled: I added a new test case function to a junit test. I run the entire class from either Eclipse or from maven, and the old case (there was only one before) runs and the new one does not. It doesn't fail. A breakpoint in it is not hit. The new function has an #Test annotation, just like the old one.
Junit version is 4.5.
Is there a way to get junit to log or trace its thought process in selecting functions to run?
I guess you still ran old class file, as new Java file was not be compiled successfully.
You could modify an old test method to see if the class is really modified: to let successful method to fail.