mirror of
https://github.com/HendrikRauh/inventree-app.git
synced 2026-01-13 11:36:24 +00:00
Merge pull request #135 from inventree/unit-testing
Unit testing
(cherry picked from commit d55f594342)
This commit is contained in:
parent
10b435f4fa
commit
cfc9f09b80
35 changed files with 893 additions and 317 deletions
46
find_dart_files.py
Normal file
46
find_dart_files.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
"""
|
||||
This script recursively finds any '.dart' files in the ./lib directory,
|
||||
and generates a 'test' file which includes all these files.
|
||||
|
||||
This is to ensure that *all* .dart files are included in test coverage.
|
||||
By default, source files which are not touched by the unit tests are not included!
|
||||
|
||||
Ref: https://github.com/flutter/flutter/issues/27997
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
dart_files = Path('lib').rglob('*.dart')
|
||||
|
||||
with open("test/coverage_helper_test.dart", "w") as f:
|
||||
|
||||
f.write("// ignore_for_file: unused_import\n\n")
|
||||
|
||||
skips = [
|
||||
'generated',
|
||||
'l10n',
|
||||
'dsn.dart',
|
||||
]
|
||||
|
||||
for path in dart_files:
|
||||
path = str(path)
|
||||
|
||||
if any([s in path for s in skips]):
|
||||
continue
|
||||
|
||||
# Remove leading 'lib\' text
|
||||
path = path[4:]
|
||||
path = path.replace('\\', '/')
|
||||
f.write(f'import "package:inventree/{path}";\n')
|
||||
|
||||
f.write("\n\n")
|
||||
|
||||
f.write("// DO NOT EDIT THIS FILE - it has been auto-generated by 'find_dart_files.py'\n")
|
||||
f.write("// It has been created to ensure that *all* source file are included in coverage data\n")
|
||||
|
||||
f.write('import "package:test/test.dart";\n\n');
|
||||
|
||||
f.write("// Do not actually test anything!\n")
|
||||
f.write("void main() {}\n")
|
||||
Loading…
Add table
Add a link
Reference in a new issue