question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Decoupling test generation and test execution

See original GitHub issue

Many of the equivalence oracles in LearnLib are based on testing (this includes RandomWordEQOracle, W(p)MethodEQOracle, CompleteExplorationEQOracle, …) and so each of these classes will contain code like this (in many flavours):

D hypOutput = output.computeOutput(queryWord);
sulOracle.processQueries(Collections.singleton(query));
if (!Objects.equals(hypOutput, query.getOutput()))
    return query;

It is a bit annoying to have to do this every time one comes up with a new test generation algorithm. My proposal is to introduce the concept of a test generator, then you implement the above code just once (i.e. one can make an equivalence oracle from any test generator).

Pros:

  • Implement test execution just once.
  • Allows to batch tests in order to execute them in parallel (now you’d have to implement this batching in each class, RandomWordEQOracle for example does this).
  • Allows to bound the test generation, withouth having to add a counter to each test generator.
  • Allows to interleave different test generation methods.

There are no cons 😉, besides having yet another abstraction.

Ideally we would implement this with coroutines, but Java does not have them. So I think iterators will do fine. Note that a collection is not sufficient, since many test generation methods are infinite. A supplier is also not sufficient because it cannot stop (some test generations methods may be finite).

In terms of interfaces, I think we would like to have two concepts. First there is the test generator, which may be just an iterator. Then there is a test generation method which has a function taking a hypothesis and returning a test generator. I have no opinion on whether we should use standard Java interfaces (like iterator) or define our own.

What are your thoughts?

Also should this be in LearnLib, or as something separate?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:2
  • Comments:14 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
fhowarcommented, Sep 6, 2016

I like the idea and think we should implement this in LearnLib!

The one method that does not match this pattern is a random walk - but I think that is OK.

1reaction
Jaxancommented, Sep 2, 2016

It would be ideal if, in turn, the test generation methods could use an up-to-date (partial) hypothesis from computeModel() to tailor their test selection procedure, but as of now I am unsure on how to achieve this.

So my plan was to have an interface TestMethod which returns an TestGenerator for every hypothesis. Meaning that you get a new test generator for each hypothesis. But maybe a single entity with some updateHypothesis function is easier to use.

What I envision for active learning is something where we can write the following (where all these components are provided in the library):

EquivalenceOracle<I, O> eqOracle = new TestingOracle(new Bound(1000, new Interleave(new WMethod(...), new LeeYannakakisMethod(...))));

where TestingOracle adapts a test method into an equivalence oracle (i.e. it is the test executor). And Bound just picks the first 1000 tests and then stops. Interleave will zip the two test methods.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Testing Framework for a decoupled Frontend and Backend
Scenario 1: Test driven development. I want it to be easy to write new tests and modify tests when developing new features. ·...
Read more >
Decoupling Dynamic Test Generation from ... - IEEE Xplore
This paper presents a new dynamic test generation technique and a tool, ReTBLDTG, short for retargetable dynamic test generation, that implements this technique ......
Read more >
Decoupling tests from implementation details - Medium
It's a testing antipattern — check “Changing implementation to make tests possible”. Test only using APIs. I don't like the rule “test all...
Read more >
How to decouple tests from code : r/ExperiencedDevs - Reddit
Tests are decoupled from each other, but not from the things they're testing. You can't test something without coupling the test code to...
Read more >
TDD: Decouple test code from production code, avoiding one ...
Basically yes. The tests are there to ensure the system has some property. Usually that the system provides some functionality. (We sometimes ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found