Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No debug output and test inputs in online editor for dataProvider #116

Open
mk-mxp opened this issue Jun 16, 2024 · 2 comments
Open

No debug output and test inputs in online editor for dataProvider #116

mk-mxp opened this issue Jun 16, 2024 · 2 comments
Assignees

Comments

@mk-mxp
Copy link
Contributor

mk-mxp commented Jun 16, 2024

While looking into this forum thread, I found that students cannot output anything to debug their code. Also the test feedback somehow is incomplete:

Code Run

): void {
    $class = new LuckyNumbers();

    $actual = $class->validate($input);

    $this->assertSame('', $actual);

Test Failure

LuckyNumbersTest::testErrorMessageForValidInput with data set #5
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-''
+'Must be a whole number larger than 0'

LuckyNumbersTest.php:138

This test file uses @dataProvider to ease coding of tests, but that must be designed to deliver acceptable test feedback (students must see test input, not "data set #5"). It is best to avoid data providers.

Anyways, there should be test output delivered when using echo or var_dump(). And that's missing.

Code submitted:

<?php

class LuckyNumbers
{
    public function sumUp(array $digitsOfNumber1, array $digitsOfNumber2): int
    {
        return \implode($digitsOfNumber1) + \implode($digitsOfNumber2);
    }

    public function isPalindrome(int $number): bool
    {
        return (string)$number == \strrev($number);
    }

    public function validate(string $input): string
    {
        echo $input;
    
        if ($input == ""){
return "Required field";
}
else if(!is_numeric($input) || intval($input) <= 0 || (intval($input)) != $input){
return "Must be a whole number larger than 0";
}
else return "";
    }
}
@mk-mxp
Copy link
Contributor Author

mk-mxp commented Jun 17, 2024

I have analysed the possible sources for including the input values into the test feedback. There is no hint in JUnit results.xml nor teamcity.txt. So this must be solved by re-designing the test files in the PHP track:

If we choose the last option (variables in @testdox) the test runner must have a test case for that, too.

@mk-mxp
Copy link
Contributor Author

mk-mxp commented Jun 17, 2024

We currently have @dataProvider in these exercises:

  • exercises/practice/protein-translation/ProteinTranslationTest.php
  • exercises/practice/binary/BinaryTest.php
  • exercises/practice/gigasecond/GigasecondTest.php
  • exercises/practice/allergies/AllergiesTest.php
  • exercises/concept/lucky-numbers/LuckyNumbersTest.php

I'll leave this issue opened for reference in PHP track exercism/php#755

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant