状態のあるコードに対するテストの自動生成


BLUE*




3







class Target(object):  # bad impl.
    def __init__(self):
        self.opened = False
        self.closed = False

    def open(self):
        self.opened = True

    def write(self):
        if not self.opened:
            raise RuntimeError
        if self.closed:
            raise RuntimeError

    def close(self):
        if not self.opened:
            raise RuntimeError
        self.closed = True

e_pluse_minusopen, close, writeo, c, w
e_plus = ['o', 'oc', 'ow', 'owc', 'oww', 'owwc', 'owww']
e_minus = ['c', 'w', 'ocw']

BLUE*DFA


DFA

4openopenDFA
4: for input ['o', 'o']: dfa said False, but target said True


    def open(self):
        if self.opened:
            raise RuntimeError
        self.opened = True

8openclosecloseDFA
8: for input ['o', 'c', 'c']: dfa said False, but target said True

2closed
class Target(object):
    def __init__(self):
        self.opened = False

    def open(self):
        if self.opened:
            raise RuntimeError
        self.opened = True

    def write(self):
        if not self.opened:
            raise RuntimeError

    def close(self):
        if not self.opened:
            raise RuntimeError
        self.opened = False



opencloseopenDFADFAe_plus
7: for input ['o', 'c', 'o']: dfa said False, but target said True

ocooe_minus
13: for input ['o', 'c', 'o', 'o']: dfa said True, but target said False


16: for input ['o', 'w', 'c', 'o']: dfa said False, but target said True


34: for input ['o', 'w', 'w', 'w', 'o']: dfa said True, but target said False

20

203 ** 203486784401531306954000

DFA35

BLUE*DFA使


  • "BLUE*: a Blue-Fringe Procedure for Learning DFA with Noisy Data" by M Sebban, J Janodet, F Tantini
  • "From Test Cases to FSMs: Augmented Test-driven Development and Property Inference" by Thomas Arts and Simon Thompson