-
Notifications
You must be signed in to change notification settings - Fork 57
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
Execution Order before_all does not get called #190
Comments
Hmm.. that's definitely a bug if from the looks of it. @BrainCrumbz something you can verify? If not, I'll take a look at Friday for sure. (Thank you for the RM congrats. I appreciate it 😄 ) |
Will have to look at this plus some other recent issues |
The new tests pass: they basically check that the right type of exception (both the internal NSpec one and the client code one) are correctly set. But then we tried creating a small sample test library with the spec classes above, and actually they still pass, while they should not. So there's something strange going on, will keep on working at this and keep you posted. |
@serialbandicoot could you try this version of NSpec and see if the problem goes away? https://www.nuget.org/packages/nspec/1.0.13 |
Small sample used: class describe_parent_before_all_throwing : nspec
{
void before_all()
{
Console.WriteLine("Parent before_all");
throw new Exception("Parent before_all");
}
/*
void before_each()
{
Console.WriteLine("Parent before_each");
throw new Exception("Parent before_each");
}
*/
}
class describe_child_before_all : describe_parent_before_all_throwing
{
void describe_test()
{
it["Should Fail"] = () =>
{
Console.WriteLine("Never make it here!");
true.ShouldBeTrue();
};
}
} Dotnet core console runner output:
VS2015 Test Explorer, still on .NET Core: Some thoughts:
Things don't change when replacing |
Same sample specs, on .NET Frramework. Output from NSpecRunner.exe:
That behavior seems the same as dotnet core console runner. But the colored output from NSpecRunner gives more info: Single spec is green, whole outcome is red. This needs to be looked at, definitely. |
Same sample specs, on .NET Framework but this time the test project is referencing NSpec 1.0.13. Maybe @serialbandicoot will confirm that too: Referencing 0.9.68: It seems the same to me, still something to be addressed though. |
Same output from NSpecRunner.exe also when referencing 1.0.7 |
@amirrajan what should be the correct behaviour?
|
Agreed.
Probably not (deferring to RSpec's behavior): describe 'before all' do
before :all do
@a = 1
raise 'exception in before all'
end
it "doesn't run" do
puts 'here'
expect(@a + 1).to eq(2)
end
end Failures:
1) before all doesn't run
Failure/Error: raise 'exception in before all'
RuntimeError:
exception in before all
# ./spec/sandbox_spec.rb:6:in `block (2 levels) in <top (required)>' |
Ok, so we have to requirements, when there's a failing, method-level
Now it's time to see why existing NSpec tests are not catching those! |
@amirrajan maybe this is for a separate issue, but what's RSpec behavior in case of throwing |
I'm back in the office (UK time) tomorrow, so I'll be able to look over any checks you need, if you keep me posted and I'll update the issue. |
Currently looking at a solution now, posting a fix branch soon. EDIT See fix/issue-190-before-all-throw and generated PR #192 |
@serialbandicoot just to mention that PR #192 has been merged recently and it aims solving this issue plus other inconsistencies still related to exceptions thrown in beforeAll/before/act/... |
I've followed the execution order page:
https://github.com/nspec/NSpec/wiki/Execution-Orders
However it does not seem to call before_all, my understanding is before_all should get called as it's included in the inherited parent?
I'm on version 3.0.7
@amirrajan Congrats again for RubyMotion 👍
The text was updated successfully, but these errors were encountered: