MThomas's avatar

Codeception test marked as Risky, but why? and what does it mean?

I have the following test in L5 using codecept for an app I'm building.

$I = new FunctionalTester($scenario);

$I->am('logged in user');
$I->wantTo('create a new project');

$I->logIn();

$I->amOnRoute('projects.create');

$I->seeAuthentication();

// Generate project data
$faker = Faker\Factory::create();
$project = [
    'name'        => $faker->sentence(3),
    'description' => $faker->paragraph(),
    'keywords'    => generateKeywordsString($faker)
];

$I->submitForm('#new_project', $project);

$I->see($project['name'], 'h1');

$I->seeInDatabase('projects', ['name' => $project['name']]);

function generateKeywordsString($faker, $maxNumberOfKeywords = 5, $maxNumberOfWordsPerKeyword = 2)
{
    for ($i = 1; $i <= rand(1,$maxNumberOfKeywords); $i++) {
        $keywords[$i] = trim($faker->sentence(rand(1, $maxNumberOfWordsPerKeyword)),'.');
    }
    return implode("\n", $keywords);
}

And the login functional helper:

public function logIn()
    {
        $I = $this->getModule('Laravel4');

        $I->amOnRoute('auth.login');
        $I->dontSeeAuthentication();
        $I->submitForm('#login', [
            'email'                 => 'test.account@jonril.com',
            'password'              => 'password',
        ]);
        $I->seeAuthentication();
    }

This test returns 'ROk' and is so marked as Risky. My first question is what does it mean if a test is marked as risky? Second question, why is this test marked as risky?

btw, if there is a better way to authenticate a user in codecept I like to hear it :)

0 likes
1 reply
MThomas's avatar
MThomas
OP
Best Answer
Level 35

I guess it was a weird hickup by the server or whatever, just ran the test again and did not get the Risky result.

Please or to participate in this conversation.