I'm in the process of building the testing suite of a large, legacy application. I have a significant number of integration tests, but no unit tests (none). I'm trying to fix that.
The catch is, the architecture of this application is that rails/ActiveRecord only handles my web-facing pieces, validation, persistence, but then the guts of the thing are performed in POROs. These POROs roughly correspond to ActiveRecords, but there is some manipulation involved in the transformation.
Since the POROs have the business logic, I want to start by unit testing them. I initially thought to use rails fixtures, but from all I can tell, rails just loads the YAML and slams it into your testing DB, that's not what I want. In fact, the rails documentation explicitly says
Fixtures are Active Record Objects
So then I thought to use what's built into Minitest, but that didn't fit either, since it provides stubs and mocks that my object-under-test is supposed to communicate with, instead of a way to persist my object into a test file.
So now I'm at a loss- How do I save off test objects, so that I can load them back into memory without going through a database?
Edit: If this is a better place for factories, that's fine too, but I already have fixtures, so I'm trying to stay in that world yet.
Aucun commentaire:
Enregistrer un commentaire