-
Notifications
You must be signed in to change notification settings - Fork 5
ami assert
petermr edited this page Aug 26, 2020
·
3 revisions
ami assert
emulates Assertions in Java and JUnit tests, and acts as a mechanism to debug the results of operations independently of procedural code or operating system.
Still under active development
A typical unit test runs a command and we test the expected behaviour or results. Java Example:
File projectDir = new File("${user.home}", "ami/"); // directory with PDFs
AMI.execute("ami --p " + projectDir + " makeproject --rawfiletypes pdf";
Assert.assertEquals("files in directory ", 33, projectDir.listFiles().size());
will test that the new directory has the right number of files. This tests the correctness of the code and also acts as a regression test
to make sure that new enhancements don't introduce bugs.
In ami3
this could be:
ami -t my/project/PMC3211491 assert --message files_in_directory expected=33 --type=dir --count --expected=16
i.e
- analyze CTree
PMC3211491
inmy/project
as a directory -
--count
the number of files. - compare with the
--expected
value - throw an error if
count
is not the expected value
ami --input fulltext.pdf -t my/project/PMC3211491 assert --type=file --size 8543000 8544000 --message size_of_file
This runs a test of type
file
on my/project/PMC3211491/fulltext.pdf
and asserts that its size is between 8543000 and 8544000 bytes (because filesizes may vary on different operating systems).