MCPcopy Index your code
hub / github.com/HtmlUnit/htmlunit / runWith

Method runWith

src/test/java/org/htmlunit/CodeStyleTest.java:410–440  ·  view source on GitHub ↗

Verifies that no direct instantiation of WebClient from a test that runs with BrowserRunner.

(final List<String> lines, final String relativePath)

Source from the content-addressed store, hash-verified

408 * Verifies that no direct instantiation of WebClient from a test that runs with BrowserRunner.
409 */
410 private void runWith(final List<String> lines, final String relativePath) {
411 if (relativePath.replace('\\', '/').contains("src/test/java")
412 && !relativePath.contains("CodeStyleTest")
413 && !relativePath.contains("WebClient9Test")
414 && !relativePath.contains("FaqTest")) {
415 boolean runWith = false;
416 boolean browserNone = true;
417 int index = 1;
418 for (final String line : lines) {
419 if (line.contains("@RunWith(BrowserRunner.class)")) {
420 runWith = true;
421 }
422 if (line.contains("@Test")) {
423 browserNone = false;
424 }
425 if (relativePath.contains("JavaScriptEngineTest") && line.contains("nonStandardBrowserVersion")) {
426 browserNone = true;
427 }
428 if (runWith) {
429 if (!browserNone && line.contains("new WebClient(") && !line.contains("getBrowserVersion()")) {
430 addFailure(relativePath, index,
431 "Never directly instantiate WebClient, please use getWebClient() instead.");
432 }
433 if (line.contains("notYetImplemented()")) {
434 addFailure(relativePath, index, "Use @NotYetImplemented instead of notYetImplemented()");
435 }
436 }
437 index++;
438 }
439 }
440 }
441
442 /**
443 * Verifies that deprecated tag is followed by "As of " or "since ", and '@Deprecated' annotation follows.

Callers 1

processMethod · 0.95

Calls 3

addFailureMethod · 0.95
containsMethod · 0.65
replaceMethod · 0.45

Tested by

no test coverage detected