-
Notifications
You must be signed in to change notification settings - Fork 62
Merge branch 'develop' into V13 #3447
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| using System; | ||
| using Castle.MicroKernel.ComponentActivator; | ||
| using NUnit.Framework; | ||
| using OSPSuite.BDDHelper; | ||
| using OSPSuite.BDDHelper.Extensions; | ||
| using OSPSuite.CLI.Core.RunOptions; | ||
| using PKSim.CLI.Core.RunOptions; | ||
|
|
||
| namespace PKSim.R | ||
| { | ||
| [IntegrationTests] | ||
| [Category("R")] | ||
| public class APISpecs : StaticContextSpecification | ||
| { | ||
| public override void GlobalContext() | ||
| { | ||
| base.GlobalContext(); | ||
| Api.InitializeOnce(); | ||
|
|
||
| Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory; | ||
| } | ||
|
|
||
| private static Exception getExceptionFromPerforming(Action work) | ||
| { | ||
| try | ||
| { | ||
| work(); | ||
| return null; | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| return ex; | ||
| } | ||
| } | ||
|
|
||
| protected static void ActionShouldNotThrowAn<TException>(Action workToPerform) where TException : Exception | ||
| { | ||
| Exception exceptionFromPerforming = getExceptionFromPerforming(workToPerform); | ||
| (exceptionFromPerforming is TException).ShouldBeFalse(); | ||
| } | ||
| } | ||
|
|
||
| public class When_resolving_tasks_after_initialization : APISpecs | ||
| { | ||
| [Observation] | ||
| public void can_get_individual_factory() | ||
| { | ||
| Api.GetIndividualFactory().ShouldNotBeNull(); | ||
| } | ||
|
|
||
| [Observation] | ||
| public void can_get_population_factory() | ||
| { | ||
| Api.GetPopulationFactory().ShouldNotBeNull(); | ||
| } | ||
|
|
||
| [Observation] | ||
| public void can_resolve_snapshot_runner() | ||
| { | ||
| ActionShouldNotThrowAn<ComponentActivatorException>(() => Api.RunSnapshot(new SnapshotRunOptions())); | ||
| } | ||
|
|
||
| [Observation] | ||
| public void can_resolve_export_runner() | ||
| { | ||
| ActionShouldNotThrowAn<ComponentActivatorException>(() => Api.RunExport(new ExportRunOptions())); | ||
| } | ||
|
|
||
| [Observation] | ||
| public void can_resolve_json_runner() | ||
| { | ||
| ActionShouldNotThrowAn<ComponentActivatorException>(() => Api.RunJson(new JsonRunOptions())); | ||
| } | ||
|
|
||
| [Observation] | ||
| public void can_resolve_qualification_runner() | ||
| { | ||
| ActionShouldNotThrowAn<ComponentActivatorException>(() => Api.RunQualification(new QualificationRunOptions())); | ||
| } | ||
|
|
||
| [Observation] | ||
| public void can_resolve_simulation_export_runner() | ||
| { | ||
| ActionShouldNotThrowAn<ComponentActivatorException>(() => Api.RunSimulationExport(new ExportRunOptions())); | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assertion helper silently passes when a different exception type is thrown.
If
workToPerformthrows an exception that is not of typeTException, the assertion still passes becauseexceptionFromPerforming is TExceptionevaluates tofalse. This masks actual failures.For resolution tests, if a dependency throws
ArgumentNullExceptioninstead ofComponentActivatorException, the test would pass incorrectly.🔧 Proposed fix to fail on any exception or specifically check resolution succeeded
Option 1 - Fail on any exception:
protected static void ActionShouldNotThrowAn<TException>(Action workToPerform) where TException : Exception { Exception exceptionFromPerforming = getExceptionFromPerforming(workToPerform); - (exceptionFromPerforming is TException).ShouldBeFalse(); + if (exceptionFromPerforming != null) + { + (exceptionFromPerforming is TException).ShouldBeFalse( + $"Expected no {typeof(TException).Name} but got: {exceptionFromPerforming}"); + } }Option 2 - If the intent is purely to test resolution, consider calling
Api.ResolveTask<T>()directly instead of invoking the full runner execution.📝 Committable suggestion
🤖 Prompt for AI Agents