Home > functions > internal > unit-test > dsUnitRun_all_jenkins.m

dsUnitRun_all_jenkins

PURPOSE ^

% Run all tests

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

% Run all tests
 excluding query tests

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% Run all tests
0002 % excluding query tests
0003 
0004 import matlab.unittest.TestSuite
0005 import matlab.unittest.TestRunner
0006 import matlab.unittest.selectors.HasTag
0007 import matlab.unittest.plugins.CodeCoveragePlugin
0008 import edu.stanford.covert.test.Coverage
0009 
0010 %% workspace
0011 fprintf('Running from dir:%s\n',pwd);
0012 [~,ws] = system('echo $WORKSPACE');
0013 ws = strtrim(ws);
0014 fprintf('Workspace:%s\n',ws);
0015 
0016 %% fix paths
0017 fprintf('Fixing paths.\n');
0018 rmPathVar('ds');
0019 addpath(genpath(ws));
0020 
0021 %% Make Default Config
0022 dsMakeDefaultConfigJenkins;
0023 
0024 %% Make Test Suite
0025 fullSuite = TestSuite.fromPackage('dsUnit');
0026 fullSuite = fullSuite.selectIf(~HasTag('query'));
0027 
0028 %% code coverage runner
0029 % runner = TestRunner.withTextOutput;
0030 % runner.addPlugin(CodeCoveragePlugin.forFolder(fullfile(dsGetConfig('ds_root_path'), 'functions')))
0031 % runner.addPlugin(CodeCoveragePlugin.forPackage('ds'))
0032 
0033 %% Run Test Suite
0034 % results = run(fullSuite); % test suite without code covereage or parallel
0035 % results = runner.run(fullSuite); % runner for code coverage
0036 
0037 %% Run Test Suite in Parallel
0038 runner = matlab.unittest.TestRunner.withTextOutput;
0039 try
0040   results = runInParallel(runner,fullSuite); % runner in parallel, no code coverage
0041   display(results);
0042 
0043   %% XML Coverage Output
0044   testCoverageDir = fullfile(ws, 'testCoverage');
0045   mkdirSilent(testCoverageDir)
0046   reportPath = fullfile(testCoverageDir, 'dsAllTestCoverageJenkins.xml');
0047   report = Coverage( fullfile(ws, 'functions'), ws );
0048   report.exportXML(reportPath);
0049   
0050   %% get coverage percentage
0051   coverPercent = report.stats.lineRate;
0052   if isnan(coverPercent)
0053     coverPercent = 0;
0054   end
0055   coverPercentStr = sprintf('%.f', coverPercent);
0056   fprintf('Test Coverage (%% of code lines): %s\n', coverPercentStr);
0057 
0058   %% make coverage svg
0059   filePath = '/home/erik/Dropbox/research/dsJenkinsBadge/coverage.svg';
0060   system(['python /home/erik/Dropbox/Programming/Python/universal_coverage_badge/__main__.py -percent ' coverPercentStr ' -o ' filePath ' -f True']);
0061 catch e
0062   disp(getReport(e,'extended'))
0063   exit(1);
0064 end
0065 
0066 exit(any([results.Failed]));

Generated on Tue 12-Dec-2017 11:32:10 by m2html © 2005