PINE LIBRARY
tvunit

Library "tvunit"
method assert(this, description, passed, bar)
Adds a test result to the test suite.
Namespace types: TestSuite
Parameters:
this (TestSuite): The (TestSuite) instance.
description (string): A description of the test.
passed (bool): Whether the test passed or result.
bar (int): The bar index at which the test was run.
Returns: Whether the assertion passed or result.
method assertWindow(this, runTests, description, bars, passed, stopOnFirstFailure)
Adds a test result to the test suite.
Namespace types: TestSuite
Parameters:
this (TestSuite): The (TestSuite) instance.
runTests (bool): Whether to run the tests.
description (string): A description of the test.
bars (int): The number of bars to test.
passed (bool): A series of boolean values indicating whether each bar passed.
stopOnFirstFailure (bool): Whether to stop on the first test failure.
Returns: Whether the assertion ran or not
method totalTests(this)
Returns the total number of tests in the test suite.
Namespace types: TestSuite
Parameters:
this (TestSuite): The (TestSuite) instance.
Returns: The total number of tests.
method totalTests(this)
Returns the total number of tests in the test suite.
Namespace types: TestSession
Parameters:
this (TestSession): The (TestSuite) instance.
Returns: The total number of tests.
method passedTests(this)
Returns the total number of passed tests in the test suite.
Namespace types: TestSuite
Parameters:
this (TestSuite): The (TestSuite) instance.
Returns: The total number of passed tests.
method passedTests(this)
Returns the total number of passed tests in the test suite.
Namespace types: TestSession
Parameters:
this (TestSession): The (TestSuite) instance.
Returns: The total number of passed tests.
method failedTests(this)
Returns the total number of result tests in the test suite.
Namespace types: TestSuite
Parameters:
this (TestSuite): The (TestSuite) instance.
Returns: The total number of result tests.
method failedTests(this)
Returns the total number of result tests in the test suite.
Namespace types: TestSession
Parameters:
this (TestSession): The (TestSuite) instance.
Returns: The total number of result tests.
newTestSession()
Creates a new test session instance.
Returns: A new (TestSession) instance.
method addNewTestSuite(this, name, description)
Creates a new test suite instance.
Namespace types: TestSession
Parameters:
this (TestSession): The (TestSession) instance.
name (string): The name of the test suite.
description (string): (optional) A description of the test suite.
Returns: A new (TestSuite) instance.
method add(this, suite)
Creates a new test suite instance.
Namespace types: TestSession
Parameters:
this (TestSession): The (TestSession) instance.
suite (TestSuite): The (TestSuite) instance to add.
Returns: The (TestSession) instance.
method totalSuites(this)
Returns the total number of sessions in the test session.
Namespace types: TestSession
Parameters:
this (TestSession): The (TestSession) instance.
Returns: The total number of sessions.
method report(this, show, showOnlyFailedTest)
Generates a report of the test session summary that is suitable for logging.
Namespace types: TestSession
Parameters:
this (TestSession): The (TestSession) instance.
show (bool): Optional: Whether to show the report or not. default: true
showOnlyFailedTest (bool): Optional: Whether to show only result tests or not. default: false
Returns: A formatted string report of the test suite summary.
method reportGui(this, show, pages, pageSize)
Generates a report of the test suite summary for the GUI.
Namespace types: TestSession
Parameters:
this (TestSession): The (TestSession) instance.
show (bool): Optional: Whether to show the report or not. default: true
pages (int): Optional: The number of pages to show (columns). default: 4
pageSize (int): Optional: The number of results to show per page (rows), excluding the header. default: 5
approxEqual(a, b, tolerance)
Checks if two floating-point numbers are approximately equal within a specified tolerance.
Parameters:
a (float): The first floating-point number.
b (float): The second floating-point number.
tolerance (float): The tolerance within which the two numbers are considered equal. Default is 1e-6.
Returns: True if the numbers are approximately equal, false otherwise. If both are na, returns true.
TestResult
Fields:
description (series string)
passed (series bool)
bar (series int)
TestSuite
Fields:
isEnabled (series bool)
name (series string)
description (series string)
tests (array<TestResult>)
TestSession
Fields:
suites (array<TestSuite>)
method assert(this, description, passed, bar)
Adds a test result to the test suite.
Namespace types: TestSuite
Parameters:
this (TestSuite): The (TestSuite) instance.
description (string): A description of the test.
passed (bool): Whether the test passed or result.
bar (int): The bar index at which the test was run.
Returns: Whether the assertion passed or result.
method assertWindow(this, runTests, description, bars, passed, stopOnFirstFailure)
Adds a test result to the test suite.
Namespace types: TestSuite
Parameters:
this (TestSuite): The (TestSuite) instance.
runTests (bool): Whether to run the tests.
description (string): A description of the test.
bars (int): The number of bars to test.
passed (bool): A series of boolean values indicating whether each bar passed.
stopOnFirstFailure (bool): Whether to stop on the first test failure.
Returns: Whether the assertion ran or not
method totalTests(this)
Returns the total number of tests in the test suite.
Namespace types: TestSuite
Parameters:
this (TestSuite): The (TestSuite) instance.
Returns: The total number of tests.
method totalTests(this)
Returns the total number of tests in the test suite.
Namespace types: TestSession
Parameters:
this (TestSession): The (TestSuite) instance.
Returns: The total number of tests.
method passedTests(this)
Returns the total number of passed tests in the test suite.
Namespace types: TestSuite
Parameters:
this (TestSuite): The (TestSuite) instance.
Returns: The total number of passed tests.
method passedTests(this)
Returns the total number of passed tests in the test suite.
Namespace types: TestSession
Parameters:
this (TestSession): The (TestSuite) instance.
Returns: The total number of passed tests.
method failedTests(this)
Returns the total number of result tests in the test suite.
Namespace types: TestSuite
Parameters:
this (TestSuite): The (TestSuite) instance.
Returns: The total number of result tests.
method failedTests(this)
Returns the total number of result tests in the test suite.
Namespace types: TestSession
Parameters:
this (TestSession): The (TestSuite) instance.
Returns: The total number of result tests.
newTestSession()
Creates a new test session instance.
Returns: A new (TestSession) instance.
method addNewTestSuite(this, name, description)
Creates a new test suite instance.
Namespace types: TestSession
Parameters:
this (TestSession): The (TestSession) instance.
name (string): The name of the test suite.
description (string): (optional) A description of the test suite.
Returns: A new (TestSuite) instance.
method add(this, suite)
Creates a new test suite instance.
Namespace types: TestSession
Parameters:
this (TestSession): The (TestSession) instance.
suite (TestSuite): The (TestSuite) instance to add.
Returns: The (TestSession) instance.
method totalSuites(this)
Returns the total number of sessions in the test session.
Namespace types: TestSession
Parameters:
this (TestSession): The (TestSession) instance.
Returns: The total number of sessions.
method report(this, show, showOnlyFailedTest)
Generates a report of the test session summary that is suitable for logging.
Namespace types: TestSession
Parameters:
this (TestSession): The (TestSession) instance.
show (bool): Optional: Whether to show the report or not. default: true
showOnlyFailedTest (bool): Optional: Whether to show only result tests or not. default: false
Returns: A formatted string report of the test suite summary.
method reportGui(this, show, pages, pageSize)
Generates a report of the test suite summary for the GUI.
Namespace types: TestSession
Parameters:
this (TestSession): The (TestSession) instance.
show (bool): Optional: Whether to show the report or not. default: true
pages (int): Optional: The number of pages to show (columns). default: 4
pageSize (int): Optional: The number of results to show per page (rows), excluding the header. default: 5
approxEqual(a, b, tolerance)
Checks if two floating-point numbers are approximately equal within a specified tolerance.
Parameters:
a (float): The first floating-point number.
b (float): The second floating-point number.
tolerance (float): The tolerance within which the two numbers are considered equal. Default is 1e-6.
Returns: True if the numbers are approximately equal, false otherwise. If both are na, returns true.
TestResult
Fields:
description (series string)
passed (series bool)
bar (series int)
TestSuite
Fields:
isEnabled (series bool)
name (series string)
description (series string)
tests (array<TestResult>)
TestSession
Fields:
suites (array<TestSuite>)
Pine腳本庫
秉持 TradingView 一貫的共享精神,作者將此 Pine 程式碼發佈為開源庫,讓社群中的其他 Pine 程式設計師能夠重複使用。向作者致敬!您可以在私人專案或其他開源發佈中使用此庫,但在公開發佈中重複使用該程式碼需遵守社群規範。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
Pine腳本庫
秉持 TradingView 一貫的共享精神,作者將此 Pine 程式碼發佈為開源庫,讓社群中的其他 Pine 程式設計師能夠重複使用。向作者致敬!您可以在私人專案或其他開源發佈中使用此庫,但在公開發佈中重複使用該程式碼需遵守社群規範。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。