Sample

Schnappinger/junit4/org.junit.runner.JUnitCore

Human rating uses the original dataset scale.

Human3.9
Lines167

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
49.2Δ 2.2
Scalabrino0.880–1; higher is more readable
83.9Δ 32.6
Dorn0.1760–1; higher is more readable
38.9Δ 12.4
Mi0.1890–1; higher is more readable
15.2Δ 36.1
LLOC40Logical lines; fewer is more readable
43.2Δ 8.1
DeepSeek V4 Pro17.670–20; mean of three runs
83.0Δ 31.7
GPT-6.1 Sol180–20; mean of three runs
73.8Δ 22.4
BTTF0.6840–1; higher is more readable
76.6Δ 25.2
Human3.91–4; original rating
51.3

Views

Source code

package org.junit.runner; import junit.runner.Version; import org.junit.internal.JUnitSystem; import org.junit.internal.RealSystem; import org.junit.internal.TextListener; import org.junit.internal.runners.JUnit38ClassRunner; import org.junit.runner.notification.RunListener; import org.junit.runner.notification.RunNotifier; /** * <code>JUnitCore</code> is a facade for running tests. It supports running JUnit 4 tests, * JUnit 3.8.x tests, and mixtures. To run tests from the command line, run * <code>java org.junit.runner.JUnitCore TestClass1 TestClass2 ...</code>. * For one-shot test runs, use the static method {@link #runClasses(Class[])}. * If you want to add special listeners, * create an instance of {@link org.junit.runner.JUnitCore} first and use it to run the tests. * * @see org.junit.runner.Result * @see org.junit.runner.notification.RunListener * @see org.junit.runner.Request * @since 4.0 */ public class JUnitCore { private final RunNotifier fNotifier = new RunNotifier(); /** * Run the tests contained in the classes named in the <code>args</code>. * If all tests run successfully, exit with a status of 0. Otherwise exit with a status of 1. * Write feedback while tests are running and write * stack traces for all failed tests after the tests all complete. * * @param args names of classes in which to find tests to run */ public static void main(String... args) { Result result = new JUnitCore().runMain(new RealSystem(), args); System.exit(result.wasSuccessful() ? 0 : 1); } /** * Run the tests contained in <code>classes</code>. Write feedback while the tests * are running and write stack traces for all failed tests after all tests complete. This is * similar to {@link #main(String[])}, but intended to be used programmatically. * * @param classes Classes in which to find tests * @return a {@link Result} describing the details of the test run and the failed tests. */ public static Result runClasses(Class<?>... classes) { return runClasses(defaultComputer(), classes); } /** * Run the tests contained in <code>classes</code>. Write feedback while the tests * are running and write stack traces for all failed tests after all tests complete. This is * similar to {@link #main(String[])}, but intended to be used programmatically. * * @param computer Helps construct Runners from classes * @param classes Classes in which to find tests * @return a {@link Result} describing the details of the test run and the failed tests. */ public static Result runClasses(Computer computer, Class<?>... classes) { return new JUnitCore().run(computer, classes); } /** * @param system * @param args from main() */ Result runMain(JUnitSystem system, String... args) { system.out().println("JUnit version " + Version.id()); JUnitCommandLineParseResult jUnitCommandLineParseResult = JUnitCommandLineParseResult.parse(args); RunListener listener = new TextListener(system); addListener(listener); return run(jUnitCommandLineParseResult.createRequest(defaultComputer())); } /** * @return the version number of this release */ public String getVersion() { return Version.id(); } /** * Run all the tests in <code>classes</code>. * * @param classes the classes containing tests * @return a {@link Result} describing the details of the test run and the failed tests. */ public Result run(Class<?>... classes) { return run(defaultComputer(), classes); } /** * Run all the tests in <code>classes</code>. * * @param computer Helps construct Runners from classes * @param classes the classes containing tests * @return a {@link Result} describing the details of the test run and the failed tests. */ public Result run(Computer computer, Class<?>... classes) { return run(Request.classes(computer, classes)); } /** * Run all the tests contained in <code>request</code>. * * @param request the request describing tests * @return a {@link Result} describing the details of the test run and the failed tests. */ public Result run(Request request) { return run(request.getRunner()); } /** * Run all the tests contained in JUnit 3.8.x <code>test</code>. Here for backward compatibility. * * @param test the old-style test * @return a {@link Result} describing the details of the test run and the failed tests. */ public Result run(junit.framework.Test test) { return run(new JUnit38ClassRunner(test)); } /** * Do not use. Testing purposes only. */ public Result run(Runner runner) { Result result = new Result(); RunListener listener = result.createListener(); fNotifier.addFirstListener(listener); try { fNotifier.fireTestRunStarted(runner.getDescription()); runner.run(fNotifier); fNotifier.fireTestRunFinished(result); } finally { removeListener(listener); } return result; } /** * Add a listener to be notified as the tests run. * * @param listener the listener to add * @see org.junit.runner.notification.RunListener */ public void addListener(RunListener listener) { fNotifier.addListener(listener); } /** * Remove a listener. * * @param listener the listener to remove */ public void removeListener(RunListener listener) { fNotifier.removeListener(listener); } static Computer defaultComputer() { return new Computer(); } }

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.3123.769−103.084
Source linesThe number of non-empty source lines.167+66.8
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.4.514−6.771

Intercept 8.87 + feature contributions = -34.186 (log-odds).
Score = sigmoid(-34.186) = 0.

Score0.88

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.168−4.912
Indentation frequencyHow rapidly indentation changes from line to line.96+2.583
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.166.86+1.923
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.96−1.782
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.105.952+0.905
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.105.976−0.824
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.046+0.496

Intercept 0.07 + feature contributions = -1.54 (log-odds).
Score = sigmoid(-1.54) = 0.176.

Score0.189
Score40
Run 1

The code is well-structured with a clear facade pattern and logical method overloads. Each method has a single, clear responsibility and is accompanied by concise Javadoc. Nesting is minimal; the only notable block is the try/finally, which is appropriately flat. Intent is unambiguous throughout. The code is concise, with no unnecessary repetition aside from minor Javadoc duplication in method overloads. Action granularity is excellent — one action per line, with no multiple statements on a single line. Reading flow is natural, moving from public API entry points to internal execution logic. The only minor drawbacks are the slightly redundant Javadoc between overloaded runClasses methods and the field name prefix 'f', but these do not significantly impact readability.

Run 2

The code is highly readable. Structure is logical: public API methods are grouped, with overloads delegated cleanly. Nesting is minimal; the only try/finally block is clear and serves resource cleanup. Intent is well-documented with Javadoc explaining each method's purpose. Code length is concise—methods are short and avoid unnecessary verbosity. Each line performs one clear action, improving granularity. Reading flow is natural, progressing from entry points (main, runClasses) to internal execution (run(Runner)) and utility methods (defaultComputer). Field naming (fNotifier) follows a consistent convention. Overall, this is a clean façade design.

Run 3

The code is well-structured with clear separation of concerns, minimal nesting, and a logical flow from entry points to core execution. Each method has a single responsibility and uses concise delegation to avoid duplication. Javadoc comments enhance clarity of intent. Minor deductions due to slight repetition in overloaded run/runClasses methods and the field prefix 'f' (Hungarian notation), which slightly reduces readability for modern Java developers.

Run 1

Code Structure: Well-organized facade with small methods separating command-line execution, request conversion, test running, and listener management. Nesting: Minimal; only a straightforward try/finally block adds depth. Clarity of intent: Descriptive method names and extensive Javadoc explain most responsibilities, although the fNotifier naming convention and vague testing-only comment slightly reduce clarity. Code length: Implementations are concise, but repeated documentation and numerous overloads lengthen the class. Action granularity: Statements generally perform one clear action per line; delegation chains remain simple. Reading flow: Consistent formatting and progression from entry points to execution and listener helpers make navigation natural, though understanding overload delegation requires some jumping between methods.

Run 2

Code Structure: Well-organized facade with small methods separating command-line execution, test execution, and listener management. Nesting: Almost entirely flat; the single try/finally clearly expresses cleanup. Clarity of intent: Descriptive method names and extensive Javadoc explain most responsibilities, although fNotifier is dated naming and the testing-only run(Runner) documentation is limited. Code length: Implementations are concise, but repeated Javadoc and numerous delegating overloads increase reading volume. Action granularity: Statements generally perform one clear action per line; constructor and method chaining remain straightforward. Reading flow: Consistent formatting and progressively delegating run methods create a natural flow, though tracing execution requires moving through several overloads. Overall, highly readable with minor documentation and navigation overhead.

Run 3

Code Structure: Well-organized facade with small methods separating command-line execution, request construction, test execution, and listener management. Nesting: Almost entirely flat; the single try/finally clearly expresses listener cleanup. Clarity of intent: Descriptive method names and extensive Javadoc explain responsibilities, although the legacy fNotifier name and vague testing-only documentation slightly reduce clarity. Code length: Implementations are concise, but repeated Javadoc and numerous forwarding overloads add reading overhead. Action granularity: Statements generally perform one clear action per line; short chained calls remain understandable. Reading flow: Execution progresses naturally from entry points through delegating overloads to the central runner method, followed by listener helpers. Overall, the code is highly readable with minor documentation and naming distractions.