Skip to content

Commit

Permalink
[#1731] Updating the Unit Testing section of the Xtext website.
Browse files Browse the repository at this point in the history
Signed-off-by: Tamas Miklossy <miklossy@itemis.de>
  • Loading branch information
miklossy committed May 4, 2020
1 parent 4802a3b commit c765d13
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions xtext-website/documentation/303_runtime_concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ import org.example.domainmodel.DomainmodelInjectorProvider
@InjectWith(DomainmodelInjectorProvider)
@RunWith(XtextRunner)
class ParserTest {
@Test void simple() {
@Test def void simple() {
assertTrue(true)
}
}
Expand All @@ -753,15 +753,15 @@ A test class for JUnit 5 looks quite similar. Instead of runners JUnit 5 has a n
```xtend
import org.eclipse.xtext.testing.InjectWith
import org.eclipse.xtext.testing.extensions.InjectionExtension
import org.junit.jupiter.api.extension.ExtendWith
import org.junit.jupiter.api.^extension.ExtendWith
import org.junit.jupiter.api.Test
import static org.junit.jupiter.api.Assertions.*
import org.example.domainmodel.DomainmodelInjectorProvider
@InjectWith(DomainmodelInjectorProvider)
@ExtendWith(InjectionExtension)
class ParserTest {
@Test void simple() {
@Test def void simple() {
assertTrue(true)
}
}
Expand Down Expand Up @@ -789,7 +789,7 @@ def void parseDomainmodel() {
}
```

### Testing Validators {#test-validators}
### Testing the Validator {#test-validators}

Testing your validation is very simple with the [ValidationTestHelper]({{site.src.xtext_core}}/org.eclipse.xtext.testing/src/org/eclipse/xtext/testing/validation/ValidationTestHelper.java):

Expand Down Expand Up @@ -850,6 +850,8 @@ public class MyLanguageStandaloneSetup extends MyLanguageStandaloneSetupGenerate

This only applies to referencing dependencies to imported Ecore models and languages based on them which may be used in the test. The inherited dependencies from mixed-in grammars are automatically listed in the generated super class already, and nothing needs to be done for those.

The Xtext example projects (*File &rarr; New &rarr; Example &rarr; Xtext Examples*) contain further unit test cases, e.g. testing the formatter, serializer, compiler, ...etc . Feel free to study the corresponding `org.eclipse.xtext.example.<language>.tests` projects to get some inspirations on how to implement automated unit test cases for your Xtext-based language.

---

**[Next Chapter: Integration with Java](305_xbase.html)**

0 comments on commit c765d13

Please sign in to comment.