6

I'm working with big set of articles from a Website. I retrieve them by querying the database and apply to this data a set of methods.

Let's write some pseudocode to clarify this context:

List<Article> articles = GetArticlesFromDatabase();

intermediateResult1 = FirstMethod(articles);

intermediateResult2 = SecondMethod(intermediateResult1 );

output = FinalMethod(intermediateResult2);

I'd like to be able to unit test FinalMethod using mocked data. And instead of writing the sample data manually I'd rather use the real data saved in a example data file at the previous execution of the software.

Is there a name for this practice? Are there patterns and frameworks to avoid reinventing the wheel?

2 Answers 2

6

Testing approaches are an essential part of software engineering and are therefore on topic here on Software Engineering (and probably also on Software Quality Assurance & Testing ).

But questions like “is there a name for this practice?” are much more tricky. They are probably not a good fit for the Stack Exchange Q&A format.

It is typically better to focus your question on a concrete software engineering problem you're having. This part describes your actual problem and could be the seed of a great question:

And instead of writing the sample data manually I'd rather use the real data saved in a example data file at the previous execution of the software.

5

I agree with amon that your question has a great start, but the final sentence

Is there a name for this practice? Are there patterns and frameworks to avoid reinventing the wheel?

will undoubtly make it prone to be downvoted, closed ("needs more focus") and deleted.

Instead, I would usually recommend to describe what you tried by yourself, where you got stuck and where precisely you think you need help. However, by the information in the question so far, I am unsure where your problems are:

  • persisting intermediateResult2 will probably be only a matter of effort, but nothing we can help you without knowing what kind of data this involves

  • same holds for getting assessment data for output and persisting it

  • and comparing the actual output against the assessment data is something we cannot really help you with, too, as long as you don't provide any details of how this data looks like and where you see any problems with it.

So a question on this site will likely be more successful when askers first try to solve their problems by themselves (and I am not speaking of the problem of finding a name for this). Good questions need to provide real world context, even when they are just conceptual questions.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .