#[test]Available on crate feature
test only.Expand description
Tests a piece of code from inside Neovim.
§Examples
ⓘ
use nvim_oxi::api;
#[nvim_oxi::test]
fn set_get_del_var() {
api::set_var("foo", 42).unwrap();
assert_eq!(Ok(42), api::get_var("foo"));
assert_eq!(Ok(()), api::del_var("foo"));
}The test function can also return a Result<(), T> if T implements
Debug:
ⓘ
#[nvim_oxi::test]
fn print_42() -> Result<(), api::Error> {
api::command("lua print(42)")
}§Attributes
§nvim-oxi
Exactly the same as the nvim-oxi attribute on the plugin macro.
See its documentation for more information.
§cmd
The cmd attribute is used to specify an Ex command that will be executed
by Neovim before the test’s body. This can be useful to configure the
environment in which the test will run.
ⓘ
#[nvim_oxi::test(cmd = "lua print('The answer is...')")]
fn print_42() -> Result<(), api::Error> {
api::command("lua print(42)")
}If the given string spans multiple lines, it will be joined into a single
line using ; as the separator.