[RFC] blackbox tests
Martin Pool
mbp at sourcefrog.net
Tue Apr 4 02:22:04 BST 2006
On 4 Apr 2006, at 11:09 , Robert Collins wrote:
> So I mentioned this in another thread as a by-the-by.
>
> I think in the blackbox tests we should avoid using bzr commands
> except
> for the ones we are testing.
>
> I.e.
> instead of
> os.mkdir('a')
> os.chdir('a')
> self.run_bzr('init')
> self.build_tree(['b'])
> self.run_bzr('add')
> self.run_bzr('commit', '-m', 'foo')
> out, err = self.run_bzr('info')
> self.assertEqual(out, '...')
> self.assertEqual(err, '...')
>
> we should do:
> tree = self.make_branch_and_tree('a')
> self.build_tree(['a/b'])
> tree.add('b')
> tree.commit('foo')
> out, err = self.run_bzr('info', cwd='a')
> self.assertEqual(out, '...')
> self.assertEqual(err, '...')
>
>
> This will reduce knock-on effects in the test suite when one command
> changes - only the tests for that command should be effected. It will
> also put pressure on the library API to provide the same functionality
> the CLI does, to avoid DRY, which will have the nice benefit of making
> it easier for plugin authors and GUI writers to do what the UI does
> without duplication.
>
> Seeking a +1 on this as a 'preferred approach', something for us to
> look
> for in reviews, and to eventually change the current tests to be like.
Yes, +1 from me.
It will require some care that manipulation through the api doesn't
keep the branch locked and so cause the commands to hang. We had a
few issues like that earlier while changing locking stuff. It's
generally fairly straightforward to debug.
--
Martin Pool
More information about the bazaar
mailing list