Hey Daniele. In several of the (third-party) major-modes I author or maintain, I use the library "assess" available on MELPA for testing fontification. See: https://melpa.org/#/assess For testing indentation, I've also created reference-documents and completely reindented them in a test and then compared the results. This provides some basic (but not complete) coverage, because (depending on the mode) interactive usage may give different results. An example. Consider the following line of c/java/javascript/php/c#- code: if (someBool) The correct indentation for the following line could be: - the same as the preceeding line if the next line contains an opening bracket ({)- nested one level deeper if it contains a direct expression. So when pressing enter... Should you indent immediately? And should you then later on correct the indentation if a user creates a block-start marker { ? I'm not sure what the right answer is, but it is an example of something which will differ in a interactive use-case vs reflowing a completed, existing document. If your major-mode has cases like this, you will have to write more elaborate tests to ensure these too are handled correctly. That said: I'm not sure if this is the recommended or canonical approach, but combining these techniques has worked for me in my projects. -- Regards Jostein Kjønigsen jostein@kjonigsen.net 🍵 jostein@gmail.com https://jostein.kjonigsen.net On Sat, Jan 19, 2019, at 4:07 PM, Daniele Nicolodi wrote: > On 15/01/2019 11:45, Yuri Khan wrote: >> On Tue, Jan 15, 2019 at 10:52 PM Daniele Nicolodi >> wrote:>> >>> I am hacking on beancount-mode (a mode to edit Beancount ledger >>> files)>>> and I would like to write some automated tests to check the >>> functionality of the minor mode. I found ERT, but it seems that >>> it does>>> not offer any facility to easily test fontification, indentation, or>>> buffer manipulation in general. >>> >>> Is there any facility that would help in writing such tests? >> >> You might want to look at ledger-mode tests. Its approach to >> fontification testing is: >> >> * Create a temporary buffer. >> * Put test text into it. >> * Harvest it back with fontification properties into a data >> structure.>> * Test that this structure is equal to the golden output. >> >> https://github.com/ledger/ledger-mode/blob/master/test/test-helper.el#L149>> https://github.com/ledger/ledger-mode/blob/master/test/fontify-test.el> > Thanks Yuri, this is very helpful. > > Cheers, > Dan > > >