Code Monkey home page Code Monkey logo

hs-test's Introduction

hs-test

It is a framework that simplifies testing educational projects for Hyperskill. It is built on top of JUnit.

It is required to use for Hyperskill projects. The main features are:

  • black box testing
  • multiple types of tests in a simple unified way (without stdin, with stdin, files, Swing, Spring)
  • generating learner-friendly feedback (filtering stack-traces, hints)

To learn how to use this library you can go here: https://github.com/hyperskill/hs-test/wiki

hs-test's People

Contributors

dependabot[bot] avatar inuur avatar meanmail avatar misterbucketman avatar msmilkshake avatar polischuks avatar servb avatar swsms avatar tanya124 avatar tony-gk avatar vyahhi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hs-test's Issues

Library in not working with Java 12

Any static variable in the solution causes

java.lang.NoSuchFieldException: modifiers at java.base/java.lang.Class.getDeclaredField(Class.java:2417) at

Out of memory creates Cannot check the submission

Error text:

"Cannot check the submission. Please send the report to Hyperskill team. 
stdout:

stderr:

FAILURE: Build failed with an exception.

* What went wrong: 
Execution failed for task ':test'. 
> Process 'Gradle Test Executor 1' finished with non-zero exit value 137 
This problem might be caused by incorrect test process configuration. 
Please refer to the test execution section in the User Manual at https://docs.gradle.org/5.3.1/userguide/java_testing.html#sec:test_execution

* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 35s"

Should show to the user full input and output of the test

For example, there can be 1/20 th chance of getting such an output.

Start test 1
Hello
>Hello
Hello
Start test 2
Hello
>Hi
Hi
Start test 3
Hello
>Hihi1
Hihi1
Start test 4
Hello
>

Start test 5
Hello
>1
>Hey
Hey
Start test 6
Hello
>2
2

Allow throwing some error as the way to fail the test

Now the test is assumed to be failed only if methods .addInput, check return CheckResult object. This can be hard if checking goes deep into several methods (for example, parsing output) and encounteres that something is wrong. Since return statement can be made only in .addInput, check you actually need to write something like:

... deep into methods
       throw new Exception(feedback);
...

... check method
List<Grid> grids;
try {
     grids = Grid.parse(out);
} catch (Exception ex) {
     return CheckResult.FALSE(ex.getMessage());
}
...

but with this issue implemented it can be something like this (less boilerplate):

... deep into methods
       throw new FailTestError(feedback);
...

... check method
List<Grid> grids = Grid.parse(out);
...

All class membes is equals to null when generating tests.

Example:

// TODO: why if this field in not static then it is null, not String[]?
static final String[] inputs = new String[] {
    "1 1", "1 2", "1 3",
    "2 1", "2 2", "2 3",
    "3 1", "3 2", "3 3"
};

This happens because tests are generated in constructor when no member fields initialized

Input need to be reset after every test

provideLines() appends text to the System.in and implies that input is empty, but sometimes it can contain some data. Need to reset System.in before every test.

"No main method found" Exception should be described friendlier

Now, it's like this:

Fatal error during testing, please send the report to Hyperskill team.

OS Mac OS X
Java 12.0.1
Vendor Oracle Corporation
Testing library version 5

Cannot be cloned: nothing
Cannot be reset: nothing
Cannot deserialize: nothing
Cannot serialize: nothing
Circular links: nothing


java.lang.Exception: No main method found
        at org.hyperskill.hstest.v5.stage.BaseStageTest.initTests(BaseStageTest.java:67)
        at org.hyperskill.hstest.v5.stage.BaseStageTest.start(BaseStageTest.java:120)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:567)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.