blog/auto-refactor-tests/auto-refactor-tests.org

44 lines
1.6 KiB
Org Mode
Raw Normal View History

2020-10-15 15:23:31 +00:00
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="https://sdf.org/~rhoder/style1.css" />
#+HTML_HEAD: <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet" />
#+HTML_HEAD: <script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML"> </script>
#+HTML_HEAD: <script type="text/x-mathjax-config"> MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});</script>
#+OPTIONS: toc:nil
#+OPTIONS: num:nil
* Auto rewrite unit tests [2018-06-11 Mon 19:33]
** Suggest
Can unit tests be reduced to a form where machines can rewrite them
automatically? A first approach might be diff'ing the parse trees
between the (current AST) and (AST previous commit). Then using the
diff to produce an automatic translation from (AST of tests from previous
commit) to the current commit.
This must be possible, maybe not with current tools, but people do it
manually all the time and it's generally regarded as one of the more
mundane tasks. Tests usually contain just enough state to test one
function or method, it's a very constrained use of the library under
test's API, so code with the least possible complexity to demonstrate
soundness.
Maybe building abstractions over the API usage itself, to describe how
it is used, a generalized test protocol. Bonus, something like this
could generate documentation.
** AutoProtocols
*** TestProtocolFoo
- construct datatype
- assert pre conditions
- test property
- assert post conditions
*** TestProtocolBarDB
- init database
- assert pre conditions
- commit data
- HTTP POST
- assert post conditions