Testing - open a testing workbook
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- csharp
- Domain
- testing-qa, tooling
Research direction
Start with the proposed WorkbookFixture in the ExcelDna.Testing assembly and inspect the XFunctions Examples workbooks, especially HelpExamples.xlsx. Review how xUnit IClassFixture is intended to supply the workbook, then resolve the issue's open questions about locating, opening, and closing test workbooks. Done means a defined fixture design that supports tests running against a pre-created workbook.
Written by the indexing model from the issue text.
Description
I think it would be nice to be able to run all the test from a class in the context of a pre-created workbook.
I'm trying to understand what the xUnit way to set this up would be.
For example, in the XFunctions add-in, I have some example workbooks:
https://github.com/Excel-DNA/XFunctions/tree/master/Examples
I want to make tests for the XFunctions add-in that execute in the context of one of those workbooks.
I suggest we add a WorkbookFixture class in the ExcelDna.Testing assembly that looks like this:
public class WorkbookFixture : IDisposable
{
public Workbook Workbook { get; }
public WorkbookFixture(string name)
{
// Look for the workbook in the test directory or somewhere close
// not sure what the path search story should be - do we allow partial paths like testbook/myBook.xlsx ?
// in practise one might want the test workbook in the test project directory, not the test output directory?
// Anyway, once we've found it we open it.
}
public Dispose() { // Close it? }
}
For the test code, maybe something like this could then work.
Suppose there is a file called HelpExamples.xlsx in a good directory.
Then the test gets a class that subclasses the WorkbookFixture, passing in the name as constructor parameter.
public class HelpExamplesFixture : base("HelpExamples.xlsx") {}
public class HelpExampleTests : IClassFixture<HelpExamplesFixture>
{
Workbook _wb;
public HelpExampleTests(HelpExamplesFixture fixture) { _wb = fixture.Workbook; };
[Fact]
public void CheckSomething()
{
Assert.Equal(_wb.Range["A1"], 123);
}
}
@Sergey-Vlasov Do you have any thoughts on how this should work?
- Dominant language
- C#
- Stars
- 0
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Excel-DNA/DeveloperTools
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Excel-DNA/DeveloperTools#24 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
Excel-DNA/DeveloperTools#16 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
Excel-DNA/DeveloperTools#15 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
Excel-DNA/DeveloperTools#14 · 4 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
All issues in Excel-DNA/DeveloperTools
Similar issues
-
Status: Waiting triage Type: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
nanoframework/Home#1857 ·
-
kind/bug kind/regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
unoplatform/uno.toolkit.ui#1646 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nightscout/nocturne#1379 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
elastic/esql-dotnet#47 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100