Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8908769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:16:04+00:00 2026-06-15T03:16:04+00:00

I’ve created a custom JUnit 4 runner(extends BlockJUnit4Runner) whose purpose is to run tests

  • 0

I’ve created a custom JUnit 4 runner(extends BlockJUnit4Runner) whose purpose is to run tests which are necessary for other tests to be valid before those tests are run. For example, if you were testing some file IO, the read/write test would require the open/close tests to work properly.

This runs the tests properly with any number of requires and reports back fine for tests that don’t require anything else, but when I run a test which does require another, I get “Done: 1 of 2”, and the event log says “Tests passed: 1 passed”. This is the case even if the requiring test(which ran second) failed.

@Override
protected void runChild(FrameworkMethod method, RunNotifier notifier) {
    if (!alreadyRunMethods.containsKey(method.getName())) {
        boolean requiredMethodsPassed = true;
        for (Annotation anno : method.getAnnotations()) {
            if (anno instanceof Requires) {
                requiredMethodsPassed = runRequiredMethods((Requires) anno, notifier, method);
                break;
            }
        }
        if (requiredMethodsPassed) {
            super.runChild(method, notifier);
        }else{
            notifier.fireTestAssumptionFailed(new Failure(describeChild(method), new AssumptionViolatedException("Required methods failed.")));
        }
    }
}

private boolean runRequiredMethods(Requires req, RunNotifier notifier, FrameworkMethod parentMethod) {
    boolean passed = true;
    for (String methodName : req.value()) {
        FrameworkMethod method = methodByName.get(methodName);
        if (method == null) {
            throw new RuntimeException(String.format("Required test method '%s' on test method '%s' does not exist.", methodName, parentMethod.getName()));
        }
        runChild(method, notifier);
        Boolean methodPassed = alreadyRunMethods.get(method.getName());
        methodPassed = methodPassed == null ? false : methodPassed;
        passed &= methodPassed;
    }
    return passed;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:16:06+00:00Added an answer on June 15, 2026 at 3:16 am

    Your custom runner should preperly define org.junit.runners.ParentRunner#getDescription then IDEA would correctly show the tree.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to run a str_replace or preg_replace which looks for certain words
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
I know there's a lot of other questions out there that deal with this
I'm trying to select an H1 element which is the second-child in its group

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.