sleuthkit / autopsy

Autopsy® is a digital forensics platform and graphical interface to The Sleuth Kit® and other digital forensics tools. It can be used by law enforcement, military, and corporate examiners to investigate what happened on a computer. You can even use it to recover photos from your camera's memory card.
http://www.sleuthkit.org/autopsy/
2.37k stars 591 forks source link

Third Party Plugin Development Unit Test #3346

Open cogwizzle opened 6 years ago

cogwizzle commented 6 years ago

So I've made some pretty good progress working through and writing myself a simple plugin that interprets CSV content. Everything seems to work as expected, but I'd like to write Unit Test for the plugin to automate testing the software. Does anyone have any experience doing this? Right now I am encountering problems managing the JAR dependencies. I am new to Jython and it has been a few years since I worked in Python. Any advice welcome.

cogwizzle commented 6 years ago

Right now this is what I have.

import os,glob,sys,fnmatch
directories = ['/home/jfehrman/Development/autopsy/',
        '/home/jfehrman/Development/sleuthkit/']

for directory in directories:
    for root, dirnames, filenames in os.walk(directory):
        for filename in fnmatch.filter(filenames, '*.jar'):
            sys.path.append(os.path.join(root, filename))

import unittest
from GenericIngest import GenericDataSourceIngestModuleFactory

class GenericDataSourceIngestModuleFactoryTest (unittest.TestCase):
    def test(self):
        self.assertEqual(4, 4)

if __name__ == '__main__':
    unittest.main()

My problem is that even though I have imported all of the jar files from the Autopsy and Sleuthkit directories I still am getting errors while importing some Sleuthkit classes like Logger (org.sleuthkit.autopsy.coreutils).

bcarrier commented 6 years ago

Hello,

No, we have never made unit tests for ingest modules, although we always talk about how we want to. The need to for so many mock services is what has stopped us.

We have made unit tests within Autopsy for other code though, but it is all done in Java using the NetBeans UI and it handles all of the JAR file madness.

We are starting to build up more automated end-to-end testing though in Autopsy, but that is probably not going to help your situation. Sorry.