-
Notifications
You must be signed in to change notification settings - Fork 0
/
component---src-docs-java-get-use-of-test-results-md-ef219ab19fae67ee3743.js
2 lines (2 loc) · 8.79 KB
/
component---src-docs-java-get-use-of-test-results-md-ef219ab19fae67ee3743.js
1
2
"use strict";(self.webpackChunkunittestbot_web=self.webpackChunkunittestbot_web||[]).push([[519],{36631:function(e,t,a){a.r(t),a.d(t,{_frontmatter:function(){return l},default:function(){return u}});var n=a(87462),i=a(63366),r=(a(15007),a(64983)),o=a(23017),s=(a(13879),["components"]),l={};void 0!==l&&l&&l===Object(l)&&Object.isExtensible(l)&&!Object.prototype.hasOwnProperty.call(l,"__filemeta")&&Object.defineProperty(l,"__filemeta",{configurable:!0,value:{name:"_frontmatter",filename:"src/docs/java/Get-use-of-test-results.md"}});var p={_frontmatter:l},m=o.Z;function u(e){var t=e.components,a=(0,i.Z)(e,s);return(0,r.kt)(m,(0,n.Z)({},p,a,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("h2",{id:"explore-test-suites"},"Explore test suites"),(0,r.kt)("h3",{id:"view-clustered-tests"},"View clustered tests"),(0,r.kt)("p",null,"Even before running tests you have them clustered into suites. Analyze them to see failing tests, explicitly thrown exceptions, and successful executions."),(0,r.kt)("p",null,"These clusters are marked as ",(0,r.kt)("em",{parentName:"p"},"Regions")," in test source code. To view all the suites at once and navigate between them, press ",(0,r.kt)("strong",{parentName:"p"},"Alt+7")," to open Structure tool window."),(0,r.kt)("p",null,"The typical suites are:"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("em",{parentName:"li"},"Fuzzer")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("em",{parentName:"li"},"Symbolic execution engine"),",")),(0,r.kt)("p",null,"each divided into:"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("em",{parentName:"li"},"Successful executions")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("em",{parentName:"li"},"Explicitly thrown unchecked exceptions")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("em",{parentName:"li"},"Error suite"))),(0,r.kt)("p",null,"Find the example below:"),(0,r.kt)("p",null,(0,r.kt)("img",{alt:"Screenshot of UnitTestBot output structure, showing test suites",src:"https://user-images.githubusercontent.com/64418523/193044976-c83d990d-3211-4218-8c07-57d628ccf780.PNG"})),(0,r.kt)("p",null,"Dive into these suites to find test methods with detailed descriptions."),(0,r.kt)("h3",{id:"read-test-descriptions"},"Read test descriptions"),(0,r.kt)("p",null,(0,r.kt)("img",{alt:"test_description",src:"https://user-images.githubusercontent.com/64418523/193581057-28d22cbf-d6c4-4c2e-b628-f0d84b991366.PNG"})),(0,r.kt)("p",null,"Each test contains:"),(0,r.kt)("h4",{id:"javadoc-comment"},"Javadoc comment"),(0,r.kt)("p",null,"Briefly describes test execution path."),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},"See ",(0,r.kt)("a",{parentName:"li",href:"https://github.com/UnitTestBot/UTBotJava/wiki/Fine-tune-test-generation#javadoc-comment-style"},"Javadoc comment style")," for configuring the ",(0,r.kt)("strong",{parentName:"li"},"Plain\ntext")," or ",(0,r.kt)("strong",{parentName:"li"},"Structured via custom Javadoc tags")," view."),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"https://www.jetbrains.com/help/idea/working-with-code-documentation.html#toggle-rendered-view"},"Render Javadoc comments")," to get more clear and structured view."),(0,r.kt)("li",{parentName:"ul"},"Jump to the method-under-test right from the comment.")),(0,r.kt)("h4",{id:"testing-framework-annotations"},"Testing framework annotations"),(0,r.kt)("p",null,"Provide a super short test method description inside:"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},"For JUnit 5: ",(0,r.kt)("inlineCode",{parentName:"p"},'@DisplayName("\\<short description>")'))),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},"For TestNG: ",(0,r.kt)("inlineCode",{parentName:"p"},'@Test(description = "\\<short description>")'),(0,r.kt)("br",null),"\n(For JUnit 4 there are no descriptions right in the annotations.)"),(0,r.kt)("p",{parentName:"li"}," ",(0,r.kt)("em",{parentName:"p"},(0,r.kt)("strong",{parentName:"em"},"Disabled (or sandboxed) tests"))),(0,r.kt)("p",{parentName:"li"}," Sometimes the tests with the ",(0,r.kt)("em",{parentName:"p"},"@Disabled")," annotation and a stack trace appear in the output:"),(0,r.kt)("p",{parentName:"li"}," ",(0,r.kt)("inlineCode",{parentName:"p"},'@Disabled("Disabled due to sandbox")')),(0,r.kt)("p",{parentName:"li"}," Keep calm: it is a feature, not a bug. These tests were sandboxed, i.e. interrupted, because they tried to execute potentially unsafe code."),(0,r.kt)("p",{parentName:"li"}," The most common forbidden actions are:"),(0,r.kt)("ul",{parentName:"li"},(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},"working with files (read, write, create, delete),")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},"connecting to sockets,")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},"invoking ",(0,r.kt)("inlineCode",{parentName:"p"},"System.exit()"),",")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},"accessing system properties or JVM properties,")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},"using reflection."),(0,r.kt)("p",{parentName:"li"},"You can ",(0,r.kt)("strong",{parentName:"p"},"add permissions")," in ",(0,r.kt)("inlineCode",{parentName:"p"},"~\\.utbot\\sandbox.policy"),". Create this file manually."),(0,r.kt)("p",{parentName:"li"},"You can refer to the ",(0,r.kt)("a",{parentName:"p",href:"https://docs.oracle.com/javase/1.5.0/docs/guide/security/spec/security-spec.doc3.html"},"Full list of permissions"),"."),(0,r.kt)("p",{parentName:"li"},"If you are sure you want the code to be executed as is (",(0,r.kt)("strong",{parentName:"p"},"including the unsafe operations!"),") you can ",(0,r.kt)("strong",{parentName:"p"},"turn sandboxing off"),": add ",(0,r.kt)("inlineCode",{parentName:"p"},"AllPermission")," to ",(0,r.kt)("inlineCode",{parentName:"p"},"~\\.utbot\\sandbox.policy"),". Be careful!"),(0,r.kt)("p",{parentName:"li"},"If you remove the ",(0,r.kt)("em",{parentName:"p"},"@Disabled")," annotation and run the test, it will be run without creating a sandbox."))))),(0,r.kt)("h4",{id:"test-method-name"},"Test method name"),(0,r.kt)("p",null,"Usually looks like ",(0,r.kt)("inlineCode",{parentName:"p"},"testMethodUnderTestName"),". Sometimes it is accompanied by explanatory supplements: e.g.,\n",(0,r.kt)("inlineCode",{parentName:"p"},"ByFuzzer"),", ",(0,r.kt)("inlineCode",{parentName:"p"},"ReturnsOneWithCornerCase"),", or others."),(0,r.kt)("h4",{id:"test-method-body"},"Test method body"),(0,r.kt)("p",null,"You can jump to the method-under-test from here too."),(0,r.kt)("h3",{id:"run-tests-and-view-coverage"},"Run tests and view coverage"),(0,r.kt)("p",null,"There are multiple ways to ",(0,r.kt)("a",{parentName:"p",href:"https://www.jetbrains.com/help/idea/performing-tests.html"},"run tests")," and ",(0,r.kt)("a",{parentName:"p",href:"https://www.jetbrains.com/help/idea/code-coverage.html"},"view coverage")," in IntelliJ IDEA. All of them apply to UnitTestBot results — feel free to choose any."),(0,r.kt)("p",null,"If you are not satisfied with coverage, try to ","[Experiment with test generation]","(Fine-tune test generation.md#Experiment with test generation to reach higher coverage)."),(0,r.kt)("h3",{id:"get-sarif-reports"},"Get SARIF reports"),(0,r.kt)("h4",{id:"what-is-sarif"},"What is SARIF?"),(0,r.kt)("p",null,"It is the ",(0,r.kt)("em",{parentName:"p"},"Static Analysis Results Interchange Format")," — a standard, JSON-based format for the output of static analysis tools."),(0,r.kt)("p",null,"Every static analysis tool has its own output format, and these formats usually have little in common. SARIF provides a universal output format, which makes it possible to create common tooling, such as viewers, bug filers, metrics calculators, etc."),(0,r.kt)("p",null,"For more information please refer to ",(0,r.kt)("a",{parentName:"p",href:"https://github.com/microsoft/sarif-tutorials/blob/main/README.md"},"SARIF Tutorials"),"."),(0,r.kt)("h4",{id:"how-to-get-sarif-report-in-unittestbot"},"How to get SARIF report in UnitTestBot"),(0,r.kt)("p",null,"By default, UnitTestBot creates SARIF reports for each test generation."),(0,r.kt)("p",null,(0,r.kt)("em",{parentName:"p"},"Note:")," if you enable ",(0,r.kt)("strong",{parentName:"p"},"Parameterized tests")," in the ",(0,r.kt)("strong",{parentName:"p"},"Generate Tests with UnitTestBot")," window, SARIF report is unavailable for now."),(0,r.kt)("p",null,"You can find SARIF reports in the ",(0,r.kt)("inlineCode",{parentName:"p"},"resources")," directory near ",(0,r.kt)("strong",{parentName:"p"},"Test sources root"),". "))}u&&u===Object(u)&&Object.isExtensible(u)&&!Object.prototype.hasOwnProperty.call(u,"__filemeta")&&Object.defineProperty(u,"__filemeta",{configurable:!0,value:{name:"MDXContent",filename:"src/docs/java/Get-use-of-test-results.md"}}),u.isMDXComponent=!0}}]);
//# sourceMappingURL=component---src-docs-java-get-use-of-test-results-md-ef219ab19fae67ee3743.js.map