alan-turing-institute / Palaeoanalytics

Repository for the Paleoanalytics project.
https://www.turing.ac.uk/research/research-projects/palaeoanalytics
GNU General Public License v3.0
17 stars 1 forks source link

A means for running tests during dev with corresponding directions #169

Closed MichaelHoltonPrice closed 1 year ago

MichaelHoltonPrice commented 2 years ago

Again, my commendations for a remarkable piece of work. One hurdle I faced was confirming that the tests in fact ran. I'm sure Travis continuous integration is a fine tool to use for testing, but it is, apparently, not easy to use during dev (or perhaps it is yet I couldn't figure out how to do so). The directions I found online suggested using Docker for local development. While I'm quite familiar with Docker, it seemed more hassle than it's worth. My guess is that during your development work you must have a way of running your tests before issuing a pull request. I suggest adding directions to the README, though I am not going to hold up publication for this.

In the end, the way I ran the tests was with the following script run from the root of the github repository. This is obviously incredibly "klugy". Despite being a seasoned programmer, however, I couldn't figure out a better way. Likely this is just ignorance on my part on how Travis CI works, but I did spend a few hours trying to figure out how to run the tests locally the "correct" way and all I was able to find were suggestions to use Docker, which I realized would be more work to do than just writing the following simple script.

import os

test_files = os.listdir('tests')

test_files = [f for f in test_files if f.endswith('.py')]

for f in test_files: print('----') print('Running tests in ' + f) file_stem = f.split('.')[0] exec('from tests import ' + file_stem) exec('functions = dir(' + filestem + ')') functions = [f for f in functions if f.startswith('test')] for func in functions: print('--') print('Calling ' + func) exec(file_stem + '.' + func + '()')

JasonGellis commented 2 years ago

@MichaelHoltonPrice @Nikoleta-v3 Test coverage documentation has been completed. I think there might me some confusion on this. We use the the pytest library. All that's needed is to go to the main Palaeoanalytics directory and type pytest -s

I have added a testing section section - Functional testing of PyLithics - in the REAME.md THis has been merged to the main branch.