Skip to content

Commit

Permalink
Report to the Console and through HTML on a suite-by-suite basis
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Yiasemides committed Jan 23, 2017
1 parent 2f8d71f commit 0f26e54
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/white_bread/command_line/suite_run.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule WhiteBread.CommandLine.SuiteRun do
end

defp run_suite(%Suite{} = suite, context_path: context_path) do
IO.puts "\n\nSuite: #{suite.name}"
WhiteBread.EventManager.report({:suite, suite.name})
ContextLoader.ensure_context(suite.context, context_path)
WhiteBread.run(
suite.context,
Expand Down
4 changes: 4 additions & 0 deletions lib/white_bread/outputers/console.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ defmodule WhiteBread.Outputers.Console do

## Interface to Generic Server Machinery

def handle_cast({:suite, name}, state) when is_binary(name) do
IO.puts("\n\nSuite: #{name}")
{:noreply, state}
end
def handle_cast({:scenario_result, result, scenario}, state) do
output_scenario_result(result, scenario)
{:noreply, state}
Expand Down
13 changes: 5 additions & 8 deletions lib/white_bread/outputers/html.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defmodule WhiteBread.Outputers.HTML do
one go.
"""

defstruct pid: nil, path: nil, tree: %{}, data: []
defstruct pid: nil, path: nil, tree: %{}, data: [], suite: <<>>

## Client Interface

Expand All @@ -32,21 +32,20 @@ defmodule WhiteBread.Outputers.HTML do
{:ok, %__MODULE__{path: document_path()}}
end

def handle_cast({:suite, name}, state) when is_binary(name) do
{:noreply, %{state | suite: name, tree: Map.put(state.tree, name, state.data), data: []}}
end
def handle_cast({:scenario_result, {result, _}, %Scenario{name: name}}, state) when :ok == result or :failed == result do
{:noreply, %{state | data: [{result, name}|state.data]}}
end
def handle_cast({:scenario_result, {_, _}, %ScenarioOutline{}}, state) do
## This clause here for more sophisticated report in the future.
{:noreply, state}
end
def handle_cast({:scenario_result, _}, state) do
def handle_cast({:final_results, %{successes: [{%Feature{name: _}, _}|_], failures: _}}, state) do
## This clause here for more sophisticated report in the future.
{:noreply, state}
end
def handle_cast({:final_results, %{successes: [{%Feature{name: x}, _}|_], failures: _}}, state) do
## This clause here for more sophisticated report in the future.
{:noreply, %{state | tree: Map.put(state.tree, x, state.data), data: []}}
end
def handle_cast(x, state) do
require Logger

Expand All @@ -55,8 +54,6 @@ defmodule WhiteBread.Outputers.HTML do
end

def terminate(_, %__MODULE__{data: content, path: path, tree: tree}) do
IO.inspect content
IO.inspect tree
report_ tree, path
end

Expand Down

0 comments on commit 0f26e54

Please sign in to comment.