JUnit STDIO

A JUnit extension to run tests with piping file inputs to STDIN and validation against STDOUT.

Лицензия

Лицензия

Категории

Категории

JUnit Тестирование компонентов
Группа

Группа

hu.webhejj.junit.stdio
Идентификатор

Идентификатор

junit-stdio
Последняя версия

Последняя версия

1.0.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

JUnit STDIO
A JUnit extension to run tests with piping file inputs to STDIN and validation against STDOUT.
Ссылка на сайт

Ссылка на сайт

https://github.com/gnagy/junit-stdio
Система контроля версий

Система контроля версий

https://github.com/gnagy/junit-stdio

Скачать junit-stdio

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/hu.webhejj.junit.stdio/junit-stdio/ -->
<dependency>
    <groupId>hu.webhejj.junit.stdio</groupId>
    <artifactId>junit-stdio</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/hu.webhejj.junit.stdio/junit-stdio/
implementation 'hu.webhejj.junit.stdio:junit-stdio:1.0.0'
// https://jarcasting.com/artifacts/hu.webhejj.junit.stdio/junit-stdio/
implementation ("hu.webhejj.junit.stdio:junit-stdio:1.0.0")
'hu.webhejj.junit.stdio:junit-stdio:jar:1.0.0'
<dependency org="hu.webhejj.junit.stdio" name="junit-stdio" rev="1.0.0">
  <artifact name="junit-stdio" type="jar" />
</dependency>
@Grapes(
@Grab(group='hu.webhejj.junit.stdio', module='junit-stdio', version='1.0.0')
)
libraryDependencies += "hu.webhejj.junit.stdio" % "junit-stdio" % "1.0.0"
[hu.webhejj.junit.stdio/junit-stdio "1.0.0"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12

Модули Проекта

Данный проект не имеет модулей.

JUnit STDIO

A JUnit extension to run tests with piping file inputs to STDIN and validation against STDOUT.

This can be useful for example when writing solutions as unit tests for coding challenges such as on HackerRank.

Example:

@RunWith(StdioSuite.class)
@StdioInputs({"000", "001"})
public class ToUpperTest {

    @Test
    public void testToUpper() throws Exception {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        String line = "";
        while ((line = stdin.readLine()) != null){
            System.out.println(line.toUpperCase());
        }
    }
}

JUnit will run testToUpper() two times based on the @StdioInputs annotation. The test runner first reads in input000.txt, pipes it to STDIN of the test and then compares its STDOUT to output000.txt. Then, the same is done for input001.txt and output001.txt respectively. The files are read as resources from the CLASSPATH in the same package where the class under test is located.

See also the unit test that comes with this project.

Downloads

Available on Maven Central.

License

Copyright 2015 Gergely Nagy greg@webhejj.hu

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Версии библиотеки

Версия
1.0.0