#CodeCoverage
Explore tagged Tumblr posts
Text
youtube
Intel Questa - Grab Your Starter Edition License for Free | Accelerate Your Design Verification
Subscribe to "Learn And Grow Community"
YouTube : https://www.youtube.com/@LearnAndGrowCommunity LinkedIn Group : https://www.linkedin.com/groups/7478922/
Blog : https://LearnAndGrowCommunity.blogspot.com/
Facebook : https://www.facebook.com/JoinLearnAndGrowCommunity/
Twitter Handle : https://twitter.com/LNG_Community
DailyMotion : https://www.dailymotion.com/LearnAndGrowCommunity
Instagram Handle : https://www.instagram.com/LearnAndGrowCommunity/
Follow #LearnAndGrowCommunity
#IntelQuesta#StarterEditionLicense#DesignVerification#AccelerateYourDesign#RTLsimulation#CodeCoverage#DebuggingCapabilities#FPGA#QuartusPrime#AlteraQuartus#QuestaforVHDL#QuestaforVerilogHDL#QuestaSimulation#QuartusforVHDL#QuartusforVerilogHDL#learnandgrowcommunity#NareshDobal#VHDL#VHDLDesign#BeginnersGuide#LearnVHDL#VHDLTutorial#VHDLLearning#VHDLCoding#VHDLProgramming#VHDLSyntax#CodingTutorial#XilinxFPGA#VerilogHDL#FPGAtools
1 note
·
View note
Link
Everything you need to know about code coverage tools and its advantages ,its disadvantage . How to to select code coverage tool ?
0 notes
Text
Test Coverage v/s Code Coverage
A product is not successful unless it serves the purpose of a business. How can you determine its viability then? A well-documented coding and techniques are not immune to human errors, thus leading to the rejection of the product. As a result, it wastes your efforts, time, and resources and above all glaring from clients.
However, thorough testing methodologies can do the tricks and ensure the effectiveness of coding. Unit testing does not always come up to your expectations and offer better testing of a product. Instead of regarding this, go with Test Coverage and Code Coverage. These two are the most comprehensive and popular testing techniques to ensure the efficacy of codes and high product quality. Let’s understand these two coding phenomena by combing their differences and specifications.
Overview: Test Coverage and Code Coverage
Test Coverage and Code coverage are measurement metrics to ease the assessment of the quality of application codes. Code coverage is used during the application is run to determine the exercise of application code. Test coverage applies to the overall test. But, both these metrics are useful and significant for developers to ensure the quality of the application efficiently.
Definition:
What is Code Coverage?
It refers to both manual and automation testing for test cases that cover the number of codes. The metrics of this type of test aims at measuring the total lines of codes and also a number of lines. The primary objective of this metric is to reduce the probabilities of bug attacks through increased length of code coverage.
To run this test, you either use the Selenium framework or any other automated framework.
What is Test Coverage?
This is a test type to ensure the functional quality of a product involving software requirement specifications and other required documents. So, test coverage is something beyond codes, rather it is concentrated on user requirements or purpose-built for expected functionality.
Ways You Can Perform Code Coverage
There are different ways you can run code coverage. You can focus on the following subtypes.
Branch coverage:
Referred to as decision coverage, it makes use of logical branches to be assessed in your code for decision-making with every existing branch. For example, if you use some variables for cross browsing compatibility testing, it is critical to ensuring you use all of the variables using adequate inputs.
Statement coverage:
This includes corner or boundary cases. These codes are the smallest units to be executable only once.
Function coverage:
It refers to a number of functions that are susceptible to be tested, for say exported functions/APIs.
Line coverage:
This is simple. It means a number of lines your code coverage has evaluated.
Ways To Perform Test Coverage
Like code coverage, Test coverage also includes several testing mechanisms. However, which test coverage is important is based upon business propositions.
Unit Testing:
This is referred to as unit testing since it is carried out at a module or unit level. This aims at assessing bug encounters which may differ from the mechanism executed during the integration level.
Functional Testing:
This metric is undertaken to comply with the Functional Requirement Specifications (FRS).
Integration Testing:
Also referred to as a system testing for software is tested on a system level. During the integration of all the necessary modules, this testing is executed.
Acceptance Testing
This is what confirms the acceptability of the final product by end-users. Acceptance testing is kind of a green signal for developers that accelerates the product launch prior to making the final code changes.
Other than these subtypes, some important test coverage is Features Coverage, Risks Coverage, and Requirement Coverage.
Pros of Code Coverage
It improves the effectiveness of test code and provides you ways to enhance the performance of coverage
Regardless of what tool is being used (open-source or something else), implementing the code coverage tool takes less time
Detects bugs in the program flow, thus improving the code quality
Pros Of Test Coverage
Part of black-box testing techniques, it does not interact much with code itself. Yet, it tests software features and maintains compliance with the requirement specifications of the product results. Hence, the isolation between tests and codes offers a straightforward testing approach.
It measures software performance and capability, thus fitting well into acceptance tests.
Characterized by black-box, it does not require much expertise to execute.
Shortcomings of Test Coverage
It is a manual approach rather than being an automated methodology. It takes time and effort to assess and build test cases.
No concrete tool is available to measure its coverage. It is a manual task that requires testing coverage against the number of tests. Hence, it is vulnerable to judgmental errors.
Shortcomings of Code Coverage
Tools used in this methodology apply to Unit test only. It necessitates checking with every test type.
No easy availability of improved code coverage tools
It is tough to comply with the available tool with your project even it is a good coverage tool
Conclusion
Software development looks for a systematic approach these days to ensure the viability and accessibility of the product. This ensures testing completeness and effectiveness of the product in the release stage.
And here test coverage and code coverage seem to be valuable for organizations. With code coverage being a white-box approach while test code being a black-box approach, you need to determine your testing requirement depending on your product specifications. Before you assign with any of the testing methodologies, forget not to decide upon your resources and tentative deadline. After all, it is indeed crucial how you can maximize your effort and resources while achieving a higher level of product satisfaction.
0 notes
Text
What are Unit Tests? How do they work? [Java]
0 notes
Text
Unit Testing dan Code Coverage 1.0
Halo-halo... Ina lagi belajar nyambi ngeblog juga biar ga lupa nih hehe :). Jadi kemungkinan akan ada update ditiap tulisannya karena proses belajar dan nulis yang berbarengan. Semoga tulisannya berfaedah ya.
13 Maret 2017
Mau bahas code coverage, btw sebetulnya ini tugas minggu lalu tapi baru dikerjain. Ina kurang sprint nih :” hiks semoga dapat segera memperbaiki management waktunya ya :”)
Mulailah saya googling sana sini akhirnya dapat referensi disini.
code coverage is a measure used to describe the degree to which the source code of a program is tested by a particular test suite.
untuk mengukurnya dapat menggunakan rumus sebagai berikut :
Code Coverage = (Number of lines of code exercised)/(Total Number of lines of code) * 100%
Jadi singkat cerita, semakin tinggi nilai code coveragenya maka kemungkinan bugsnya semakin kecil. Tapi jangan lupa juga code coverage yang rendah bukan berarti terdapat banyak bug melainkan bisa saja design testing kita yang kurang bagus.
Kelompok kami menggunakan laravel dan ternyata laravel sudah menyediakan library code coverage sendiri, yaitu PHPUnit. Lanjut kesini ya :)
0 notes
Photo
Reflections on Node.js Knockout Competition 2011 https://t.co/GDVHUGEw3D #nko #heatwave #davidwee #heatmap #curl #joshuaholbrook #codecoverage #node #nodejs #replicants #jameshalliday #nodejsknockout
0 notes
Link
An integral part of SDLC, Code Coverage, which is a white-box testing technique, measures how the code is executed during the process of testing. Moreover, it helps ensure that no line of code or area of the program is left untouched for the testing purpose.
0 notes
Text
3:14 PM how to check code coverage in eclipse using sonarqube - Google Search www.google.com 3:14 PM Generate Codecoverage Report with Jacoco and Sonarqube | by Teten Nugraha | Backend Habit | Medium medium.com 3:14 PM how to check code coverage in eclipse using sonarqube - Google Search www.google.com 3:14 PM how to check code coverage in eclipse using sonarqube - Google Search www.google.com 3:14 PM how to check code coverage in eclipse using sonarqube - Google Search www.google.com 3:13 PM junit coverage eclipse - Google Search www.google.com 3:12 PM kafka circuit breaker - Google Search www.google.com 3:09 PM safe deposit box chase - Google Search www.google.com 3:08 PM google - Google Search www.google.com 3:07 PM spa application - Google Search www.google.com 3:07 PM spa application - Google Search www.google.com 3:03 PM g - Google Search www.google.com 3:02 PM Google www.go 3:14 PM how to check code coverage in eclipse using sonarqube - Google Search www.google.com 3:14 PM Generate Codecoverage Report with Jacoco and Sonarqube | by Teten Nugraha | Backend Habit | Medium medium.com 3:14 PM how to check code coverage in eclipse using sonarqube - Google Search www.google.com 3:14 PM how to check code coverage in eclipse using sonarqube - Google Search www.google.com 3:14 PM how to check code coverage in eclipse using sonarqube - Google Search www.google.com 3:13 PM junit coverage eclipse - Google Search www.google.com 3:12 PM kafka circuit breaker - Google Search www.google.com 3:09 PM safe deposit box chase - Google Search www.google.com 3:08 PM google - Google Search www.google.com 3:07 PM spa application - Google Search www.google.com 3:07 PM spa application - Google Search www.google.com 3:03 PM g - Google Search www.google.com 3:02 PM Static keyword in Java - Javatpoint www.javatpoint.com 3:16 PM java 8 features - Google Search www.google.com 3:24 PM static methods java - Google Search www.google.com 3:24 PM Static methods vs Instance methods in Java - GeeksforGeeks www.geeksforgeeks.org 3:23 PM Java Static Method | Static Keyword In Java | Edureka www.edureka.co 3:23 PM new dependency conflicting indentify jar - Google Search www.google.com 3:21 PM Detecting dependency conflicts with Maven - Stack Overflow stackoverflow.com 3:21 PM new dependency conflicting jar - Google Search www.google.com 3:20 PM java - Maven dependency resolution (conflicted) - Stack Overflow stackoverflow.com 3:18 PM Solving Dependency Conflicts in Maven - DZone Java dzone.com 3:18 PM new dependency in project - Google Search www.google.com 3:18 PM jenkins new dependency - Google Search www.google.com 3:18 PM jenkins - Google Search www.google.com 3:02 PM Inbox (32,370) - [email protected] - Gmail mail.google.com 3:31 PM datatype in bean - Google Search www.google.com 3:31 PM datatype in bean boolean - Google Search www.google.com 3:31 PM boolean vs boolean java - Google Search www.google.com 3:30 PM Boolean vs boolean in Java - Stack Overflow stackoverflow.com 3:27 PM Getting Started | Building a RESTful Web Service spring.io 3:25 PM Collections in Java - javatpoint www.javatpoint.com 3:25 PM java collections - Google Search www.google.com 3:24 PM Static keyword in Java - Javatpoint www.javatpoint.com 3:16 PM java 8 features - Google Search www.google.com 3:24 PM static methods java - Google Search www.google.com 3:24 PM Static methods vs Instance methods in Java - GeeksforGeeks www.geeksforgeeks.org 3:23 PM Java Static Method | Static Keyword In Java | Edureka www.edureka.co 3:23 PM new dependency conflicting indentify jar - Google Search www.google.com 3:21 PM Detecting dependency conflicts with Maven - Stack Overflow stackoverflow.com 3:21 PM new dependency conflicting jar - Google Search www.google.com 3:20 PM java - Maven dependency resolution (conflicted) - Stack Overflow stackoverflow.com 3:18 PM Solving Dependency Conflicts in Maven - DZone Java dzone.com 3:18 PM new dependency in project - Google Search www.google.com 3:18 PM jenkins new dependency - Google Search www.google.com 3:18 PM jenkins - Google Search www.google.com 3:
0 notes
Link
Apprendre à faire des tests unitaires en Swift avec Xcode, un tutoriel de Vincent Composieux #ChrisTec #Xcode #CodeCoverage #StarWars Chers membres du club,J'ai le plaisir de vous présenter ce tutoriel de Vincent Composieux qui va vous apprendre à faire des tests unitaires en Swift avec Xcode. Nous allons voir ensemble un nouveau tutoriel de l'espace sous iOS/Xcode. Le sujet : les tests unitaires ! Le but de ce tutoriel est de vous sensibiliser aux tests sous Xcode et de vous apporter les bases pour vous lancer. N'hésitez pas à écrire un commentaire si vous avez des questions ou autres. Bonne... #Xcode #CodeCoverage #StarWars
0 notes
Text
Angular 2, Travis CI, Coveralls and Open Sauce
In this post, we are going to see how we can make an Angular 2 app work with Travis CI, Coveralls and Open Sauce.
In a previous post, we saw how to set up a PHP project using Travis CI, StyleCI and Codecov. We are now going to do quite the same, but with a small Angular 2 app. Our purpose here is to test our app under multiple environments on each commit.
So the first thing we need to do is to sign up for a GitHub account, then we will have access to Coveralls with that same account. The next thing is to open another account on Open Sauce. We are now ready to begin! Let's create our repository, commit and push!
To achieve our goal, it is important that our project runs with angular-cli. We are going to assume that is the case and that Git is also installed.
Dependencies
For a start, we need to install several dependencies with NPM. Let's do it like so in the terminal:
npm install karma-coverage karma-coveralls karma-firefox-launcher angular-cli-ghpages --save-dev
Install dependencies
With that last command, we installed karma-coverage that is responsible for code instrumentation and coverage reporting. karma-coveralls will help us to transmit the report to Coveralls. karma-firefox-launcher is a Karma plugin that will help us with our tests. Finally, angular-cli-ghpages will help us to deploy our app on GitHub Pages.
Karma
Now we need to set a few things in the karma.conf.js file that is included in the root of our folder. The file will look like so:
module.exports = function (config) { config.set({ basePath: '', frameworks: ['jasmine', '@angular/cli'], plugins: [ require('karma-jasmine'), require('karma-chrome-launcher'), require('karma-firefox-launcher'), require('@angular/cli/plugins/karma'), require('karma-coverage') ], client:{ clearContext: false // leave Jasmine Spec Runner output visible in browser }, files: [ { pattern: './src/test.ts', watched: false } ], preprocessors: { 'dist/app/**/!(*spec).js': ['coverage'], './src/test.ts': ['@angular/cli'] }, mime: { 'text/x-typescript': ['ts','tsx'] }, coverageReporter: { dir : 'coverage/', reporters: [ { type: 'html' }, { type: 'lcov' } ] }, angularCli: { config: './angular-cli.json', codeCoverage: 'coverage', environment: 'dev' }, reporters: config.angularCli && config.angularCli.codeCoverage ? ['progress', 'coverage'] : ['progress'], port: 9876, colors: true, logLevel: config.LOG_INFO, autoWatch: true, browsers: ['Chrome', 'Firefox'], singleRun: false }); };
karma.conf.js file
Karma is a test runner that is ideal for writing and running unit tests while developing the application.
Protractor
We are now going to configure Protractor for e2e testing. There is already a file for that in the root of our folder, but is only suitable for local tests with a single browser. Let's create a new one a folder called config. We will name that file protractor.sauce.conf.js and it will be like the following:
var SpecReporter = require('jasmine-spec-reporter').SpecReporter; var buildNumber = 'travis-build#'+process.env.TRAVIS_BUILD_NUMBER; exports.config = { sauceUser: process.env.SAUCE_USERNAME, sauceKey: process.env.SAUCE_ACCESS_KEY, allScriptsTimeout: 72000, getPageTimeout: 72000, specs: [ '../dist/out-tsc-e2e/**/*.e2e-spec.js', '../dist/out-tsc-e2e/**/*.po.js' ], multiCapabilities: [ { browserName: 'safari', platform: 'macOS 10.12', name: "safari-osx-tests", shardTestFiles: true, maxInstances: 5 }, { browserName: 'chrome', platform: 'Linux', name: "chrome-linux-tests", shardTestFiles: true, maxInstances: 5 }, { browserName: 'chrome', platform: 'macOS 10.12', name: "chrome-macos-tests", shardTestFiles: true, maxInstances: 5 }, { browserName: 'chrome', platform: 'Windows 10', name: "chrome-latest-windows-tests", shardTestFiles: true, maxInstances: 5 }, { browserName: 'firefox', platform: 'Linux', name: "firefox-linux-tests", shardTestFiles: true, maxInstances: 5 }, { browserName: 'firefox', platform: 'macOS 10.12', name: "firefox-macos-tests", shardTestFiles: true, maxInstances: 5 }, { browserName: 'firefox', platform: 'Windows 10', name: "firefox-latest-windows-tests", shardTestFiles: true, maxInstances: 5 }, { browserName: 'internet explorer', platform: 'Windows 10', name: "ie-latest-windows-tests", shardTestFiles: true, maxInstances: 5 }, { browserName: 'MicrosoftEdge', platform: 'Windows 10', name: "edge-latest-windows-tests", shardTestFiles: true, maxInstances: 5 } ], sauceBuild: buildNumber, directConnect: false, baseUrl: 'YOUR_GITHUB_PAGE', framework: 'jasmine', jasmineNodeOpts: { showColors: true, defaultTimeoutInterval: 360000, print: function() {} }, useAllAngular2AppRoots: true, beforeLaunch: function() { require('ts-node').register({ project: 'e2e' }); }, onPrepare: function() { jasmine.getEnv().addReporter(new SpecReporter()); } };
protractor.sauce.conf.js file
We can notice that there are two environment values: SAUCE_USERNAME and SAUCE_ACCESS_KEY. We can set theses values in our Travis CI account in the settings sections of our project. The information can be found in our Sauce Labs account settings.
Protractor is an end-to-end test framework for Angular. Protractor runs tests against our application running in a real browser, interacting with it as a user would.
e2e configuration
In the e2e folder of our application, we need to place a file called tsconfig.json.
{ "compileOnSave": false, "compilerOptions": { "declaration": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, "module": "commonjs", "moduleResolution": "node", "outDir": "../dist/out-tsc-e2e", "sourceMap": true, "target": "es5", "typeRoots": [ "../node_modules/@types" ] } }
tsconfig.json file in e2e folder
We also need to place a similar file at the root of our application.
{ "compileOnSave": false, "compilerOptions": { "outDir": "./dist/out-tsc", "baseUrl": "src", "sourceMap": true, "declaration": false, "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "es5", "typeRoots": [ "node_modules/@types" ], "lib": [ "es2016", "dom" ] } }
tsconfig.json file
End-to-end (e2e) tests explore the application as users experience it. In e2e testing, one process runs the real application and a second process runs Protractor tests that simulate user behavior and assert that the application respond in the browser as expected.
Coveralls
In our folder, we are now going to create a file called .coverall.yml with the token corresponding to our respository that can be found in our Coveralls account.
repo_token: YOUR_TOKEN
.coverall.yml file
Travis CI
Now it is time to tell Travis CI what to do with our files. Let's create a file called .travis.yml and fill it like so:
language: node_js sudo: true dist: trusty node_js: - '6' branches: only: - master env: global: - CHROME_BIN=/usr/bin/google-chrome - DISPLAY=:99.0 cache: directories: - node_modules before_install: - ./scripts/install-dependencies.sh - ./scripts/setup-github-access.sh after_success: - ./scripts/delete-gh-pages.sh - git status - npm run build-gh-pages - npm run deploy-gh-pages - git checkout master - sleep 10 - tsc -p e2e - npm run e2e ./config/protractor.sauce.conf.js notifications: email: false
.travis.yml file
GitHub Token
Before we go any further, we need to create an access token on our GitHub account. We can do that in the settings of our account.
Scripts
In the previous section, we told Travis CI to use three bash scripts: install-dependencies.sh, setup-github-access.sh and delete-gh-pages.sh. We are now going to create a folder called scripts and create those three different scripts like so:
The first script, as its name lets us figure out, just install our dependencies.
#!/bin/bash export CHROME_BIN=/usr/bin/google-chrome export DISPLAY=:99.0 #Install chrome stable version sh -e /etc/init.d/xvfb start sudo apt-get update sudo apt-get install -y libappindicator1 fonts-liberation wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb sudo dpkg -i google-chrome*.deb rm -f google-chrome-stable_current_amd64.deb
install-dependencies.sh file
The second script ensures that we can access to our GitHub repository during the build. We can see in this script that a variable called $GH_TOKEN is used. This environment variable can be set in Travis CI by clicking on Settings in our repositories list.
#!/bin/bash set -e echo "machine github.com" >> ~/.netrc echo "login [email protected]" >> ~/.netrc echo "password $GITHUB_TOKEN" >> ~/.netrc
setup-github-access.sh file
The last script deletes the branch gh-pages to let us deploy our app on GitHub Pages (we can't do it if the branch is already here).
#!/bin/bash set -e git ls-remote --heads | grep gh-pages > /dev/null if [ "$?" == "0" ]; then git push origin --delete gh-pages fi
delete-gh-pages.sh file
Now, we need to tell GitHub and Travis CI that these files are executable. We can do that with the following command:
chmod +x the_file
Git command to change chmod
Perhaps the following command may also be needed:
git update-index --chmod=+x the_file
Git command to update index
package.json
We now have to make a few adjustments in our package.json file, more specifically, in the scripts section. We can see that use once again the $GH_TOKEN variable.
"scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test --code-coverage true --watch false && cat ./coverage/*/lcov.info | ./node_modules/coveralls/bin/coveralls.js", "lint": "ng lint", "pree2e": "webdriver-manager update --standalone false --gecko false", "e2e": "protractor", "build-gh-pages": "ng build --prod --base-href \"/YOUR_REPOSITORY/\"", "deploy-gh-pages": "angular-cli-ghpages --repo=https://[email protected]/YOUR_USERNAME/YOUR_REPOSITORY.git --name=YOUR_USERNAME --email=YOUR_EMAIL" }
package.json file
app.po.ts
We need to make one last adjustment in the file called app.po.ts that we can find in the e2e folder. Let's make it like so:
import { browser, element, by } from 'protractor'; export class BookreaderPage { navigateTo() { browser.ignoreSynchronization = true; return browser.get(browser.baseUrl); } getParagraphText() { return element(by.css('app-root h1')).getText(); } }
app.po.ts file
Here we go!
Now, we can push (again) our files and, if everything is alright, the magic will happen! We just have to check Travis CI, Coveralls and Sauce Labs.
0 notes
Text
Code Coverage now available for PowerShell Core!
This is the first of a series of posts on PowerShell Core and the tools we use to test it. If you’ve looked at the main project for PowerShell (http://ift.tt/2bAoJHu, you may have noticed a new badge down in the Build status of nightly builds:
We are supplying code coverage numbers for our test pass via the OpenCover project (http://ift.tt/1ALp78B) and we visualize our code coverage percentage via coveralls.io (http://ift.tt/2jEG9ZJ). This means you can see some details about our testing and how much of PowerShell is covered by our test code.
You can get your own coverage numbers easily via our OpenCover module which may be found in the <RepoRoot>test/tools/OpenCover directory. To generate a code coverage report, you need to create a build which supports code coverage. Currently, that’s only available on Windows, but we do have an easy way to get it:
(All of these commands assume that you are at the root of the PowerShell repo)
# create a code coverage build. PS> Start-PSBuild -Configuration CodeCoverage -Publish # Now that you have a build, save away the build location PS> $psdir = split-path -parent (get-psoutput) # Import the OpenCover Module PS> Import-module $pwd/test/tools/OpenCover # install the opencover package PS> Install-OpenCover $env:TEMP # now invoke a coverage test run PS> Invoke-OpenCover -OutputLog Coverage.xml -test $PWD/test/powershell -OpenCoverPath $env:Temp/OpenCover -PowerShellExeDirectory $psdir
If you want to get code coverage for only the tests that we run in our Continuous Integration (CI) environment, add the parameter -CIOnly. Then you’ll need to wait for a bit (on my system and using -CIOnly, it takes about 2.5 hours to run).
Looking at the Data
The OpenCover module can also help you visualize the results from a very high level.
# first collect the coverage data with the Get-CodeCoverage cmdlet PS> $coverData = Get-CodeCoverage .\Coverage.xml # here’s the coverage summary PS> $coverData.CoverageSummary NumSequencePoints : 309755 VisitedSequencePoints : 123779 NumBranchPoints : 105816 VisitedBranchPoints : 39842 SequenceCoverage : 39.96 BranchCoverage : 37.65 MaxCyclomaticComplexity : 398 MinCyclomaticComplexity : 1 VisitedClasses : 2005 NumClasses : 3309 VisitedMethods : 14912 NumMethods : 33910 # you can look at coverage data based on the assembly PS> $coverData.Assembly | ft AssemblyName, Branch, Sequence AssemblyName Branch Sequence ------------ ------ -------- powershell 100 100 Microsoft.PowerShell.CoreCLR.AssemblyLoadContext 45.12 94.75 Microsoft.PowerShell.ConsoleHost 22.78 23.21 System.Management.Automation 41.18 42.96 Microsoft.PowerShell.CoreCLR.Eventing 23.33 28.57 Microsoft.PowerShell.Security 12.62 14.43 Microsoft.PowerShell.Commands.Management 14.69 16.76 Microsoft.PowerShell.Commands.Utility 52.72 54.40 Microsoft.WSMan.Management 0.36 0.65 Microsoft.WSMan.Runtime 100 100 Microsoft.PowerShell.Commands.Diagnostics 42.99 46.62 Microsoft.PowerShell.LocalAccounts 0 0 Microsoft.PowerShell.PSReadLine 6.98 9.86
I’m not going to go through all the different properties that are reported, we’ll take a closer look at those in future posts. The Get-CoverageData cmdlet is still fairly rudimentary, but it will provide some details. This is part of our public repo, so I encourage you to enhance it and log issues if you find them!
Better Coverage Visualization
Another way to view coverage data is via the ReportGenerator package, which creates HTML reports and provides much more details about the coverage. The ReportGenerator package is available via the find-package cmdlet in the PackageManagement module. The following will install the package, and show how to run it:
# find and install the report generator package PS> find-package ReportGenerator -ProviderName nuget -Source http://ift.tt/1fBuddE | install-package -Scope CurrentUser PS> $ReportGenExe = “$HOME\AppData\Local\PackageManagement\NuGet\Packages\ReportGenerator.2.5.2\tools\ReportGenerator.exe” # invoke the report generator and create the report in c:\temp\Coverage PS> & $ReportGenExe -reports:Coverage.xml -targetdir:c:\temp\Coverage
Now that you’ve created the reports, you can visualize them with your browser.
PS> invoke-item C:\temp\Coverage\index.htm
Click on the “Enable filtering button”, and then “Collapse all” and you should see something similar to:
You can then drill in on what interests you (Microsoft.PowerShell.Commands.Utility, for example)
Of course, there’s a lot more detail to discover, and I encourage you to poke around. In my next post, I’ll go through an entire workflow:
Select an area for improvement
Create new tests
Gather new coverage data
Compare results from previous runs
I’ll target something specific (a cmdlet) and show how to determine the gaps and how to fill them.
Call To Action!
Now that you see how easily you can generate code coverage data, this is a great opportunity to provide some additional coverage and increase the quality of our releases. If you see some area which you’re passionate about or notice an area which you would like to measure better, it’s a great way to provide improved coverage. As you create new PRs, you can aim for high coverage in your new functionality (85-90%), and now you can measure it!
from DIYS http://ift.tt/2jEBqa6
0 notes
Link
Salesforceを使ったプロジェクトを最近久しぶりにやっています。その中でSalesforceの ISVパートナーになり開発したアプリケーションをAppExchange (Salesforce Store) で配布しようと考えています。その道程の中での気づきや学びを共有していきます。 結論から言うと CIもCD も出来るけど CD に関してはちょっとクセあり?まずは、CDについて解説したいと思います。CIは次回以降解説します。 環境としては GitHub, Salesforce Developer Experience, と Cloud Build を使います。 さて、ソースコードの統合がCIによってうまくいくと今度は本番環境に対してデプロイを高度に自動化していくことになります。これがまさにCD (Continuous Deployment)でやる部分です。(Delivery までではなく、Deploymentまでがやりたいことです。) 目次 管理パッケージをどうやってSalesforceでデプロイするか?開発したコードを本番環境にデプロイするには、AppExchangeの場合だと、それをパッケージ化して、最新パッケージを顧客の環境にインストールすることによって実現します。 もちろんAppExchangeで配布しているアプリケーションなので、たくさんのSalesforce 組織に対してパッケージがインストールされている状態においてもスケーラブルに高度に制御して行きたいと思います。 2nd Gen Managed Package (第二世代管理パッケージ) についてSalesforceでパッケージを作るのは従来とても自動化出来るような作業じゃありませんでした。UI上から人間がコンポーネントを一つずつチェックするようなイメージです。ヒューマンエラーが発生して当たり前の世界です。これが今では第一世代管理パッケージと呼ばれる古い方法です。プロの開発者はもうこれを使うのをやめましょう。(キッパリ) 説明は省きますが、今回はCLIで自動化が可能な第二世代管理パッケージを使います。詳しくはこちら。 パッケージとバージョンのライフサイクル 実態としてソースコード (メタデータ)が含まれるのはバージョンの方です。パッケージはAppExchangeでリスティングする単位を表すのでただの箱です。パッケージに紐付く��で無数のバージョンがあり、その中で安定しているバージョンをリリース (Promote、昇格とも言う)して、本番環境にデプロイします。 ちなみにリリースされていないバージョンの事をBetaバージョンといいます。 パッケージとバージョンの作り方前提条件: DevHub組織が作られている (sfdx clientでデフォルトになっている) 名前空間組織が作られている DevHub組織が名前空間組織を認識しているまずはパッケージを作ります。コマンド一発で出来ます。 sfdx force:package:create --name PACKAGE_NAME \ --packagetype Managed --path force-app/0Ho から始まるパッケージIDが作成されたはずです。そのIDにAliasとしてsfdx-package.json に記録しておきましょう。 次にそのパッケージに紐づくバージョンを作ります。 VERSION_NUM=1.0.0 sfdx force:package:version:create --package "PACKAGE_NAME" \ --installationkeybypass \ --definitionfile config/project-scratch-def.json \ --codecoverage --versionname="ver $VERSION_NUM" \ --versionnumber=$VERSION_NUM.NEXTちなみに二回目以降にバージョンを作成をして、そのバージョンで既存のお客様をアップデートさせる場合はAncestor IDを sfdx-project.json で指定してあげる必要があります。sfdx コマンドのオプションとして指定が出来ないようなので、毎回 JSONファイルを編集する必要があるのが微妙ですね。特に自動化する時に。。。 { "packageDirectories": [ { "path": "force-app", "default": true, "package": "PACKAGE_NAME", "ancestorId": "04t3h000004bchBAAQ" } ], "namespace": "YOUR_NAMESPACE", "sfdcLoginUrl": "https://login.salesforce.com", "sourceApiVersion": "48.0", "packageAliases": { "PACKAGE_NAME": "0Hoxxxxxxxxxxxxxxxx" } }パッケージのバージョンを作成とインストール時の制約この辺の制約は結構複雑です。調べ始めていて意味不明のエラーで何度も挫けそうになりました。あまり文献としてまとまっていなかったように思うので、ここにまとめます。あとに続く開発者の肥やしになればと・・・ パッケージのバージョンを作る際にバージョン番号を命名してあげることがあります。しかし、Git Tagの様にに任意の文字列でつけることが出来ません。 MAJOR.MINOR.PATCH.BUILDで、バージョン番号は必ず構成されます。任意の文字列を名付ける事は出来なくて、ネーミングとアップグレードにはかなり厳密なルールがあります。Buildいらなくない? と思いましたが、Versionは一度作ると消せないので、あるのだと思います。 パッケージバージョン作成時の制約網羅的なものではないと思いますが、パッケージを作成する際の制約事項をまとめました。 • Build バージョンは一つしかPromote (Release) することが出来ない。 例) 1.0.0.1 を Promoteしたら 1.0.0.2 は Promote 出来ない。 • Patch バージョンは、Security Reviewを通っていないと作れない。 例) 1.0.0.1 → 1.0.1.1 はSecurity Reviewをパスしないと作れない • Build バージョンは同じAncestor IDを持っている必要がある 例) 1.0.0.1 と 1.0.0.2 は同じAncestor IDを指定しないと行けない • 破壊的な変更がある場合は Ancestryを分けなければならない。 例) 1.0.0.1 → 1.1.0.1 の移行で DummyController.cls を削除した場合、1.1.0.1 のAncestor IDで1.0.0.1を指定することが出来ない。Ancestorがないバージョンを作らなければならない。Security Reviewに通ってないとPatch バージョンが作れないので、デバッグしただけ、見た目変えただけ、とかでもMinor バージョンを上げないといけない・・・ということが発生します。これはかなりイケてないです。(semantic versioning) あと第二世代管理パッケージではソースコードを消せません (破壊的な変更)。クラスやLightning Componentを作ったあとに削除して新しいバージョンを作ろうとするとエラーが出ます。詳しくはこちら 使わなくなったクラスや、Lightning Component、Lighting App、Connected Appなどが消せないとソースコードのボリュームが無駄に増えて非衛生的ですし、何よりもチームメイトが混乱してしまいます。苦肉の策ですが、削除が出来ない代わりにゴミ箱フォルダーをソースコードに作ってそこに入れてゴミコードであることの意思表示をしています。これ本当にどうにかして欲しいです。 パッケージバージョンを組織にインストールする際の制約• Betaパッケージはアップグレード出来ない。 • バージョンはアップグレードのみ可能。 例) 1.0.1.2 から 1.0.0.1 には戻せない。 • 古いパッケージからアップグレードする際は、直系の子孫じゃないとアップグレードが出来ない。3つ目がものすごくややこしくて鬼門です。ここを次に丁寧に説明します。ちなみに「直系の子孫」は、僕が勝手に作った言葉です。 直系の子孫の定義Major / Minor バージョンのリリースを上位パッケージ (Ancestor ID) で数珠つなぎにして一直線に並べたものと考えればわかりやすいと思います。例えばこの図の様なバージョン構成です。 1人で、1機能ずつ開発したらこんな感じになると思います。この場合、上から下の方向であれば全ての組み合わせでアップグレードが出来ます。 ----------------- なお、直系の子孫かどうかの判断に Patch / Build バージョンは関係ありません。 例えばこの様な場合は、1.0.1.1 も 1.0.2.1も直系とみなされます。よって、例えば 1.0.1.1 から 1.1.0.1アップグレードすることは可能です。 ----------------- さて、多くの開発者にとって混乱を招きやすいのはこのパターンだと思います。 0.2.0.1 を上位に持つ系統が2つ出来ました。(今まで伝統的に長男が家業を継いで来た一族である世代で長女も暖簾分けしてもらって同時に継いだイメージ?) ただしこの場合、系統をまたいだアップグレードは出来ません。例えば 1.3.0.1 から 1.4.0.1 はアップグレード出来ません。アップグレードするならばアンインストールして再インストールしか方法がありません。 ----------------- 応用ですが、以下の様な2つ系統があり、なおかつパッチバージョンがある場合のことも想定してみます。 1.2.1.1 から 1.4.0.1 はアップグレードは出来ませんが、 1.2.1.1 から 1.3.0.1 はアップグレード可能です。 Salesforce の Branch != Git の Branchこのようにツリー形式でバージョニングする事をSalesforceではBranchと呼びます。 名前で誤解をしていたので理解するのにとても苦労したのですがSalesforce の Branch は Merge が出来ません。なので一度系統が分かれてしまったら二度と元に戻ることが出来ません。元に戻すにはパッケージをアンインストールして、最新のバージョンを再インストールするしか方法がありません。 感想複数の機能を同時に複数の組織で開発して、終わったらマージして一つのパッケージに・・・といったデプロイ手法を考えていたのですが、 2nd Generation Packagingは残念ながらこの様な開発は出来ないようです。これは正直期待していたのでちょっと残念です。という点で今回は一番やりたかったCDが出来ませんでした。 まとめ (ベストプラクティス)Git を使って複数の機能を複数人で作っている場合、Git で複数のfeature branchを使いながら開発をする事になると思います。Feature branchからパッケージバージョンを作る事はやめましょう。系統が複数できて、マスターにマージができなくなる自体が発生します。 パッケージバージョンを作るのは、必ずMaster Branchから作るべきです。例えばGitHubを使っている場合であれば Release の機能を使ってパッケージバージョンを作るのがもっとも良いと思います。 そうすればパッケージバージョンはGitHubのリリースと同期することになり、見通しが良くなります。Ancestryのツリーが一本になりAbandoned Packageがなくなり、全ての組織が最新パッケージにアップグレード出来るようになります。 大分長くなってしまったので、今回は制限についての正しい情報についての解説と出来なかった事とそれからの示唆をまとめた投稿になりました。 ぶっちゃけまだまだ課題はありますが、Salesforceも大分、昔に比べるとモダンな開発がしやすくなって来たと思います。 次回は、Cloud Buildを使いながら、どのようにデプロイしていくかを書こうと思います。 もしよかったらスキとSalesforce開発者へ拡散お願いします。
0 notes
Text
Node.js Code Coverage with Istanbul and Mocha
Code coverage is a measure of how much of your code has been tested. Code coverage tools run a set of metrics in order to determine if your code has been completely tested, reducing the chance of unwanted bugs.
You have to take into account that even if your code has 100% code coverage, that doesn’t guarantee all your tests are correct, there are some logical bugs you might miss, but as with…
View On WordPress
0 notes
Link
Last week, I had a heated but interesting Twitter debate about Code Coverage with my long-time friend (and sometimes squash partner) Freddy Mallet. The essence of my point is the following: the Code Coverage metric that most quality-conscious software engineers cherish doesn’t guarantee anything. via Pocket
0 notes