Testing/it: Difference between revisions

From FreeCAD Documentation
(Created page with "Aggiungi funzione di test")
No edit summary
 
(35 intermediate revisions by 3 users not shown)
Line 2: Line 2:


{{Docnav/it
{{Docnav/it
|[[Debugging/it|Correggere i bug]]
|[[Debugging/it|Debugging]]
|[[FreeCAD_Build_Tool/it|Strumento di costruzione di FreeCAD]]
|[[FreeCAD_Build_Tool/it|Strumento di compilazione di FreeCAD]]
}}
}}


Line 10: Line 10:
{{TOCright}}
{{TOCright}}


<span id="Introduction"></span>
== Introduzione ==
== Introduzione ==


Line 40: Line 41:
Per eseguire un test da FreeCAD, passare all'Ambiente Test, quindi {{MenuCommand|Test commands → TestToolsGui → Self test → Select test name}}, quindi immettere il nome del file Python con i test; ad esempio, per l' [[Draft Workbench/it| Ambiente Draft]], sarebbe {{MenuCommand|TestDraft}}, quindi premere {{Button|Start}}.
Per eseguire un test da FreeCAD, passare all'Ambiente Test, quindi {{MenuCommand|Test commands → TestToolsGui → Self test → Select test name}}, quindi immettere il nome del file Python con i test; ad esempio, per l' [[Draft Workbench/it| Ambiente Draft]], sarebbe {{MenuCommand|TestDraft}}, quindi premere {{Button|Start}}.


<span id="Test_functions"></span>
== Funzioni di test ==
== Funzioni di test ==


Line 70: Line 72:
=== TestDraft ===
=== TestDraft ===


Aggiungi funzione di test
Add test function


<div class="mw-translate-fuzzy">
=== TestSketcherApp ===
=== TestSketcherApp ===
Add test function
</div>


Aggiungi funzione di test
Add test function


<div class="mw-translate-fuzzy">
=== TestPartApp ===
=== TestPartApp ===
Add test function
</div>


Aggiungi funzione di test
Add test function


<div class="mw-translate-fuzzy">
=== TestPartDesignApp ===
=== TestPartDesignApp ===
Add test function
</div>


Aggiungi funzione di test
Add test function


=== TestPathApp ===
=== TestCAMApp ===


Path workbench test cases:
Ambiente Path casistiche di test:
* depthTestCases:
* depthTestCases:
* PathTestUtils:
* PathTestUtils:
Line 118: Line 111:
* TestPathUtil: Test various functions available in the PathUtil module.
* TestPathUtil: Test various functions available in the PathUtil module.
* TestPathVcarve: Test general functionality of Vcarve operation.
* TestPathVcarve: Test general functionality of Vcarve operation.
* TestPathVoronoi:
* TestPathVoronoi:


<div class="mw-translate-fuzzy">
=== Workbench ===
=== Workbench ===
Add test function
</div>


Aggiungi funzione di test
Add test function


<div class="mw-translate-fuzzy">
=== Menu ===
=== Menu ===
Add test function
</div>


Aggiungi funzione di test
Add test function


<div class="mw-translate-fuzzy">
=== Menu.MenuDeleteCases ===
=== Menu.MenuDeleteCases ===
Add test function
</div>


Aggiungi funzione di test
Add test function


<div class="mw-translate-fuzzy">
=== Menu.MenuCreateCases ===
=== Menu.MenuCreateCases ===
Add test function
</div>


Aggiungi funzione di test
Add test function


==Scripting==
==Scripting==


{{Emphasis|See also:}} [[FreeCAD_Scripting_Basics|FreeCAD Scripting Basics]].
{{Emphasis|Vedere anche:}} [[FreeCAD_Scripting_Basics/it|Script di base per FreeCAD]]


<span id="Get_a_list_of_all_top-level_test_modules"></span>
===Get a list of all top-level test modules===
===Ottienere un elenco di tutti i moduli di test di primo livello===


{{Code|code=
{{Code|code=
Line 158: Line 140:
}}
}}


Si noti che i moduli di test restituiti qui dipendono dal fatto che una GUI sia disponibile o meno. Cioè, quando viene eseguito in modalità console, mancano vari test che terminano in "Gui".
Note that the test modules returned here depend on whether a GUI available or not. I.e. when executed in console mode, various tests ending in "Gui" are missing.


<span id="Run_specific_tests"></span>
===Run specific tests===
===Eseguire test specifici===


There are various ways of running tests using [https://docs.python.org/3/library/unittest.html Python's unittest library]. FreeCAD's test framework removes some of the boiler plate for the most common cases.
Esistono vari modi per eseguire test utilizzando [https://docs.python.org/3/library/unittest.html Python's unittest library]. Il framework di test di FreeCAD porta alla luce i casi più comuni.


Eseguire tutti i test definiti in un modulo Python:
Run all tests defined in a Python module:
{{Code|code=
{{Code|code=
import Test, TestFemApp
import Test, TestFemApp
Line 170: Line 153:
}}
}}


Eseguire tutti i test definiti in una classe Python:
Run all tests defined in a Python class:
{{Code|code=
{{Code|code=
import Test, femtest.app.test_solver_calculix
import Test, femtest.app.test_solver_calculix
Line 176: Line 159:
}}
}}


<span id="Example_1"></span>
===Example 1===
===Esempio 1===


Within the Python Console of FreeCAD, the following code format may be used to run built-in tests. Replace the red "'''TestFem'''" text in the code below with the desired module test name.
All'interno della console Python di FreeCAD, il seguente formato di codice può essere utilizzato per eseguire test incorporati. Sostituire il testo rosso "'''TestFem'''" nel codice sottostante con il nome del test del modulo desiderato.
* For example, use "'''TestPathApp'''" to run all unit tests for the Path workbench unit test framework.
* Ad esempio, utilizzare "'''TestPathApp'''" per eseguire tutti gli unit test per il framework di unit test Path workbench.
* Submodules are available using dot notation, like "'''TestPathApp.TestPathAdaptive'''" to only run the Adaptive unit tests within the greater Path workbench test framework.
* I sottomoduli sono disponibili utilizzando la notazione a punti, ad esempio "'''TestPathApp.TestPathAdaptive'''" per eseguire solo gli unit test adattivi all'interno del framework di test workbench Path più grande.
* Multiple test modules or submodules may be combined by adding another `'''suite.addTest(...)'''` method call just like the one in the code below, but with a different module or submodule reference.
* Più moduli di test o sottomoduli possono essere combinati aggiungendo un'altra chiamata al metodo `'''suite.addTest(...)'''` proprio come quella nel codice seguente, ma con un modulo o un riferimento di sottomodulo diverso.
* Output for the code below will be in the Report View panel within the FreeCAD GUI.
* L'output per il codice riportato di seguito sarà nel pannello Report View all'interno della GUI di FreeCAD.
* Code source is copied from post by FreeCAD forum user, ''sgrogan'', in the [https://forum.freecadweb.org/viewtopic.php?style=3&p=153251#p153251 unit tests per python] topic, with credit there given to forum user, ''wmayer''.
* Il codice sorgente è copiato dal post dell'utente del forum FreeCAD, ''sgrogan'', nell'argomento [https://forum.freecadweb.org/viewtopic.php?style=3&p=153251#p153251 unit test per python], con credito dato all'utente del forum, ''wmayer''.


{{Code|code=
{{Code|code=
Line 193: Line 177:
}}
}}


<span id="Additional_Resources"></span>
==Additional Resources==
==Risorse aggiuntive==


<span id="Forum_Topics"></span>
===Forum Topics===
===Argomenti del Forum===


* [https://forum.freecadweb.org/viewtopic.php?style=3&f=27&t=18379 Support for running specific unit tests with --run-test #331]
* [https://forum.freecadweb.org/viewtopic.php?style=3&f=27&t=18379 Support for running specific unit tests with --run-test #331]
Line 201: Line 187:


{{Docnav/it
{{Docnav/it
|[[Debugging/it|Correggere i bug]]
|[[Debugging/it|Debugging]]
|[[FreeCAD_Build_Tool/it|Strumento di costruzione di FreeCAD]]
|[[FreeCAD_Build_Tool/it|Strumento di compilazione di FreeCAD]]
}}
}}



Latest revision as of 19:57, 23 April 2024

Test workbench icon

Introduzione

Test Framework non è in realtà un ambiente di modellazione, ma contiene un set di script Python per eseguire diversi test sui componenti principali di FreeCAD, al fine di eseguire il debug dei problemi. Vedere anche come individuare gli errori.

Puoi avviare i test dalla riga di comando, usando le opzioni -t o --run-test.

Avvia tutti i test:

freecad --run-test 0

Avvia solo alcuni test specificati, per esempio

freecad -t TestDraft

Se un test non ha bisogno della GUI, può anche essere eseguito in modalità console impostando l'opzione -c o --console in aggiunta. Questo di solito si traduce in tempi di avvio molto più rapidi poiché la GUI non viene caricata. Per esempio:

freecad -c -t TestPartDesignApp

Test menu

Ogni directory di primo livello in FreeCAD dovrebbe avere un file con i test che possono essere eseguiti per quel particolare ambiente di lavoro o modulo. Il file di solito inizia con la parola Test.

Per eseguire un test da FreeCAD, passare all'Ambiente Test, quindi Test commands → TestToolsGui → Self test → Select test name, quindi immettere il nome del file Python con i test; ad esempio, per l' Ambiente Draft, sarebbe TestDraft, quindi premere Start.

Funzioni di test

Questa è la lista delle applicazioni di test di 0.15 Git 4207:

TestAPP.All

Aggiungi funzione di test

BaseTests

Aggiungi funzione di test

UnitTests

Aggiungi funzione di test

Document

Aggiungi funzione di test

UnicodeTests

Aggiungi funzione di test

MeshTestsApp

Aggiungi funzione di test

TestDraft

Aggiungi funzione di test

TestSketcherApp

Aggiungi funzione di test

TestPartApp

Aggiungi funzione di test

TestPartDesignApp

Aggiungi funzione di test

TestCAMApp

Ambiente Path casistiche di test:

  • depthTestCases:
  • PathTestUtils:
  • TestDressupDogbone: Test functionality of Dogbone dressup.
  • TestHoldingTags: Test functionality of Holding Tags dressup.
  • TestPathAdaptive: Test selection capability of Adaptive operation.
  • TestPathCore: Test core functionality of Path workbench.
  • TestPathDeburr: Test general functionality of Deburr operation.
  • TestPathGeom: Test various functions available in the PathGeom module.
  • TestPathHelix: Test general functionality of Helix operation.
  • TestPathLog: Test various functions available in the PathLog debugging and feedback module.
  • TestPathOpTools:
  • TestPathPreferences: Test various functions available in the PathPreferences module.
  • TestPathPropertyBag:
  • TestPathSetupSheet:
  • TestPathStock:
  • TestPathThreadMilling:
  • TestPathTool:
  • TestPathToolBit:
  • TestPathToolController:
  • TestPathTooltable:
  • TestPathUtil: Test various functions available in the PathUtil module.
  • TestPathVcarve: Test general functionality of Vcarve operation.
  • TestPathVoronoi:

Workbench

Aggiungi funzione di test

Menu

Aggiungi funzione di test

Menu.MenuDeleteCases

Aggiungi funzione di test

Menu.MenuCreateCases

Aggiungi funzione di test

Scripting

Vedere anche: Script di base per FreeCAD

Ottienere un elenco di tutti i moduli di test di primo livello

FreeCAD.__unit_test__

Si noti che i moduli di test restituiti qui dipendono dal fatto che una GUI sia disponibile o meno. Cioè, quando viene eseguito in modalità console, mancano vari test che terminano in "Gui".

Eseguire test specifici

Esistono vari modi per eseguire test utilizzando Python's unittest library. Il framework di test di FreeCAD porta alla luce i casi più comuni.

Eseguire tutti i test definiti in un modulo Python:

import Test, TestFemApp
Test.runTestsFromModule(TestFemApp)

Eseguire tutti i test definiti in una classe Python:

import Test, femtest.app.test_solver_calculix
Test.runTestsFromClass(femtest.app.test_solver_calculix.TestSolverCalculix)

Esempio 1

All'interno della console Python di FreeCAD, il seguente formato di codice può essere utilizzato per eseguire test incorporati. Sostituire il testo rosso "TestFem" nel codice sottostante con il nome del test del modulo desiderato.

  • Ad esempio, utilizzare "TestPathApp" per eseguire tutti gli unit test per il framework di unit test Path workbench.
  • I sottomoduli sono disponibili utilizzando la notazione a punti, ad esempio "TestPathApp.TestPathAdaptive" per eseguire solo gli unit test adattivi all'interno del framework di test workbench Path più grande.
  • Più moduli di test o sottomoduli possono essere combinati aggiungendo un'altra chiamata al metodo `suite.addTest(...)` proprio come quella nel codice seguente, ma con un modulo o un riferimento di sottomodulo diverso.
  • L'output per il codice riportato di seguito sarà nel pannello Report View all'interno della GUI di FreeCAD.
  • Il codice sorgente è copiato dal post dell'utente del forum FreeCAD, sgrogan, nell'argomento unit test per python, con credito lì dato all'utente del forum, wmayer.
import unittest
suite = unittest.TestSuite()
suite.addTest(unittest.defaultTestLoader.loadTestsFromName("TestFem"))
r = unittest.TextTestRunner()
r.run(suite)

Risorse aggiuntive

Argomenti del Forum