Test terminal can set dimensions
- ShellTest now has fields which can be used to change terminal default widht/height. - Backed by properties so can be used with `spring.shell.test.terminal-width` and `spring.shell.test.terminal-height`. - Backport #656 - Fixes #659
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
[[using-shell-testing-basics]]
|
||||
==== Basics
|
||||
=== Basics
|
||||
ifndef::snippets[:snippets: ../../test/java/org/springframework/shell/docs]
|
||||
|
||||
Spring Shell provides a number of utilities and annotations to help when testing your application.
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
[[using-shell-testing-settings]]
|
||||
=== Settings
|
||||
ifndef::snippets[:snippets: ../../test/java/org/springframework/shell/docs]
|
||||
|
||||
Built in emulation uses terminal width 80 and height 24 on default.
|
||||
Changing dimensions is useful if output would span into multiple
|
||||
lines and you don't want to handle those cases in a tests.
|
||||
|
||||
These can be changed using properties `spring.shell.test.terminal-width`
|
||||
or `spring.shell.test.terminal-height`.
|
||||
|
||||
====
|
||||
[source, java, indent=0]
|
||||
----
|
||||
include::{snippets}/TestingSnippets.java[tag=testing-shelltest-dimensions-props]
|
||||
----
|
||||
====
|
||||
|
||||
`ShellTest` annotation have fields `terminalWidth` and `terminalHeight`
|
||||
which can also be used to change dimensions.
|
||||
|
||||
====
|
||||
[source, java, indent=0]
|
||||
----
|
||||
include::{snippets}/TestingSnippets.java[tag=testing-shelltest-dimensions-field]
|
||||
----
|
||||
====
|
||||
@@ -16,3 +16,5 @@ NOTE: Testing support is currently under development and will be
|
||||
unstable for various parts.
|
||||
|
||||
include::using-shell-testing-basics.adoc[]
|
||||
|
||||
include::using-shell-testing-settings.adoc[]
|
||||
|
||||
@@ -81,4 +81,23 @@ class TestingSnippets {
|
||||
}
|
||||
}
|
||||
// end::testing-shelltest-noninteractive[]
|
||||
|
||||
class Dump1 {
|
||||
|
||||
// tag::testing-shelltest-dimensions-props[]
|
||||
@ShellTest(properties = {
|
||||
"spring.shell.test.terminal-width=120",
|
||||
"spring.shell.test.terminal-height=40"
|
||||
})
|
||||
class ShellSettingsSample {}
|
||||
// end::testing-shelltest-dimensions-props[]
|
||||
}
|
||||
class Dump2 {
|
||||
|
||||
// tag::testing-shelltest-dimensions-field[]
|
||||
@ShellTest(terminalWidth = 120, terminalHeight = 40)
|
||||
class ShellSettingsSample {}
|
||||
// end::testing-shelltest-dimensions-field[]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user